We are looking into supporting 3D geometries in vidi-editor. We are, however, stuck using 2D variations of our datasets and using database triggers to support the 3rd dimension.
looking at the code for getting the geometry from in the sql class, gc2 forces the geometry into 2D - but why?
|
$postgisVersion = $this->postgisVersion(); |
|
$bits = explode(".", $postgisVersion["version"]); |
|
if ((int)$bits[0] < 3 && (int)$bits[1] === 0) { |
|
$ST_Force2D = "ST_Force_2D"; // In case of PostGIS 2.0.x |
|
} else { |
|
$ST_Force2D = "ST_Force2D"; |
|
} |
|
|
|
// Get column types |
|
$select = $this->prepare("select * from ($q) as foo LIMIT 0"); |
|
$convertedParameters = []; |
|
if ($parameters) { |
|
foreach ($parameters as $field => $value) { |
|
$nativeType = $typeHints[$field] ?? 'json'; |
|
$formatT = $typeFormats[$field] ?? self::getFormat($nativeType); |
|
$convertedParameters[$field] = $this->convertToNative($nativeType, $value, $formatT); |
|
} |
|
$select->execute($convertedParameters); |
|
} else { |
|
$select->execute(); |
|
} |
|
foreach (range(0, $select->columnCount() - 1) as $column_index) { |
|
$meta = $select->getColumnMeta($column_index); |
|
$columnTypes[$meta['name']] = $meta['native_type']; |
|
} |
|
|
|
$fieldsArr = []; |
|
foreach ($columnTypes as $key => $type) { |
|
if ($type == "geometry") { |
|
if (in_array($format, ["geojson", "ndjson", "json"]) || (($format == "csv" || $format == "excel") && $geoformat == "geojson")) { |
|
$fieldsArr[] = "ST_asGeoJson(ST_Transform($ST_Force2D(\"$key\"),$this->srs)) as \"$key\""; |
|
} elseif ($format == "csv" || $format == "excel") { |
|
$fieldsArr[] = "ST_asText(ST_Transform($ST_Force2D(\"$key\"),$this->srs)) as \"$key\""; |
|
} |
|
} elseif ($type == "bytea") { |
|
$fieldsArr[] = "encode(\"$key\",'escape') as \"$key\""; |
|
} else { |
|
$fieldsArr[] = "\"$key\""; |
|
} |
|
} |
|
$fieldsStr = implode(",", $fieldsArr); |
|
$sql = "SELECT $fieldsStr FROM ($q) AS foo LIMIT $limit"; |
We are looking into supporting 3D geometries in vidi-editor. We are, however, stuck using 2D variations of our datasets and using database triggers to support the 3rd dimension.
looking at the code for getting the geometry from in the sql class, gc2 forces the geometry into 2D - but why?
geocloud2/app/models/Sql.php
Lines 148 to 189 in 8d6a87a