public getFormatsForType ( array $source_definition ) : array | ||
$source_definition | array | |
return | array |
public function getFormatsForType($source_definition)
{
$formats = [];
$source_type = strtolower($source_definition['type']);
switch ($source_type) {
case 'xml':
if ($source_definition['geo_formatted']) {
$formats['Map'] = 'map';
$formats['KML'] = 'kml';
$formats['GeoJSON'] = 'geojson';
$formats['WKT'] = 'WKT';
} else {
$formats['XML'] = 'xml';
}
break;
case 'kml':
$formats['Map'] = 'map';
$formats['KML'] = 'kml';
$formats['GeoJSON'] = 'geojson';
$formats['WKT'] = 'WKT';
break;
case 'json':
if ($source_definition['jsontype'] == 'GeoJSON') {
$formats['Map'] = 'map';
$formats['GeoJSON'] = 'geojson';
} elseif ($source_definition['jsontype'] == 'JSON-LD') {
$formats['JSON-LD'] = 'jsonld';
} else {
$formats['JSON'] = 'json';
}
break;
case 'shp':
$formats['Map'] = 'map';
$formats['GeoJSON'] = 'geojson';
$formats['KML'] = ' ';
$formats['WKT'] = 'WKT';
$formats['CSV'] = 'csv';
break;
case 'mongo':
$formats['JSON'] = 'json';
break;
case 'elasticsearch':
$formats['JSON'] = 'json';
break;
case 'rdf':
break;
case 'sparql':
$formats['JSON'] = 'json';
if ($source_definition['query_type'] == 'construct') {
$formats['NT'] = 'ntriples';
$formats['TTL'] = 'Turtle';
$formats['RDF'] = 'RDF';
$formats['JSON-LD'] = 'JSON-LD';
} elseif ($source_definition['query_type'] == 'select') {
$formats['CSV'] = 'CSV';
$formats['JSON'] = 'JSON';
}
break;
case 'xls':
$formats['JSON'] = 'json';
$formats['CSV'] = 'csv';
break;
case 'mysql':
$formats['JSON'] = 'json';
$formats['CSV'] = 'csv';
break;
case 'csv':
$formats['JSON'] = 'json';
$formats['CSV'] = 'csv';
break;
}
return $formats;
}
public function getDescriptionInfo($identifier) { $definition = $this->getEloquentDefinition($identifier); $properties = array(); $source_definition = $definition->source()->first(); foreach ($definition->getFillable() as $key) { $properties[$key] = $definition->{$key}; } $properties['type'] = strtolower($source_definition->type); $properties['description'] = @$source_definition->description; // Get the formats based on the source definition meta-data $format_helper = new FormatHelper(); $formats = $format_helper->getFormatsForType($source_definition->toArray()); $properties['formats'] = $formats; $properties['identifier'] = $identifier; unset($properties['map_property']); return $properties; }