$depth++; $atts["base"] = "gml:AbstractFeatureType"; writeTag("open", "xsd", "extension", $atts, True, True); $depth++; writeTag("open", "xsd", "sequence", NULL, True, True); $atts = null; $depth++; $sql = "SELECT * FROM settings.getColumns('geometry_columns.f_table_name=''{$table}'' AND geometry_columns.f_table_schema=''{$postgisschema}''',\n 'raster_columns.r_table_name=''{$table}'' AND raster_columns.r_table_schema=''{$postgisschema}''')"; $fieldConfRow = $postgisObject->fetchRow($postgisObject->execQuery($sql)); $fieldConf = json_decode($fieldConfRow['fieldconf']); foreach ($fieldsArr[$table] as $hello) { $atts["nillable"] = "true"; $atts["name"] = $hello; $properties = json_decode($fieldConf->{$atts}["name"]->properties); if ($gmlUseAltFunctions[$table]['changeFieldName']) { $atts["name"] = changeFieldName($atts["name"]); } $atts["maxOccurs"] = "1"; $selfclose = true; if ($tableObj->metaData[$atts["name"]]['type'] == "geometry") { $sql = "SELECT * FROM settings.getColumns('geometry_columns.f_table_name=''{$table}'' AND geometry_columns.f_table_schema=''{$postgisschema}'' AND f_geometry_column=''{$atts["name"]}''',\n 'raster_columns.r_table_name=''{$table}'' AND raster_columns.r_table_schema=''{$postgisschema}''')"; $typeRow = $postgisObject->fetchRow($postgisObject->execQuery($sql)); $def = json_decode($typeRow['def']); if ($def->geotype && $def->geotype !== "Default") { if ($def->geotype == "LINE") { $def->geotype = "LINESTRING"; } $typeRow['type'] = "MULTI" . $def->geotype; } switch ($typeRow['type']) { case "POINT":
/** * * * @param unknown $table * @param unknown $sql * @param unknown $sql2 * @param unknown $from */ function doSelect($table, $sql, $sql2, $from) { global $db; global $depth; global $postgisObject; global $srs; global $gmlNameSpaceUri; global $lf; global $gmlNameSpace; global $gmlNameSpaceGeom; global $gmlFeature; global $gmlGeomFieldName; global $gmlUseAltFunctions; global $defaultBoundedBox; global $cacheDir; global $startTime; global $useWktToGmlInPHP; global $thePath; global $HTTP_FORM_VARS; global $tableObj; global $postgisschema; global $fieldConfArr; if (!$gmlFeature[$table]) { $gmlFeature[$table] = $table; } if ($sql2) { $postgisObject->execQuery("BEGIN"); $result = $postgisObject->execQuery($sql2 . $from); //logfile::write($sql2.$from."\n"); if ($postgisObject->numRows($result) == 1) { while ($myrow = $postgisObject->fetchRow($result)) { if (!empty($myrow["txmin"])) { //added NR genBBox($myrow["txmin"], $myrow["tymin"], $myrow["txmax"], $myrow["tymax"]); } else { //return; } } } else { print $defaultBoundedBox; } } else { print $defaultBoundedBox; } $result = $postgisObject->execQuery($sql . $from . " LIMIT 1000000"); if ($postgisObject->numRows($result) < 1) { $sql = str_replace(",public.ST_AsText(public.ST_Transform(the_geom,25832)) as the_geom", "", $sql); $from = str_replace("view", "join", $from); $result = $postgisObject->execQuery($sql . $from); } logfile::write("SQL fired\n\n"); logfile::write($sql . $from . "\n"); $totalTime = microtime_float() - $startTime; logfile::write("\nQuery time {$totalTime}\n"); //foreach($postgisObject -> execQuery($sql.$from." LIMIT 10000") as $myrow) { //Iteration directly over result. Only PDO if ($postgisObject->PDOerror) { makeExceptionReport($postgisObject->PDOerror); } while ($myrow = $postgisObject->fetchRow($result)) { writeTag("open", "gml", "featureMember", null, True, True); $depth++; writeTag("open", $gmlNameSpace, $gmlFeature[$table], array("fid" => "{$table}.{$myrow["fid"]}"), True, True); $depth++; $checkIfGeomHasPassed = false; // Check that geom field is written out only once. $numFields = sizeof($myrow); $keys = array_keys($myrow); for ($i = 0; $i < $numFields; $i++) { $FieldName = $keys[$i]; $FieldValue = $myrow[$FieldName]; if ($tableObj->metaData[$FieldName]['type'] != "geometry" && $FieldName != "txmin" && $FieldName != "tymin" && $FieldName != "txmax" && $FieldName != "tymax" && $FieldName != "tymax" && $FieldName != "oid") { if ($gmlUseAltFunctions['altFieldValue']) { $FieldValue = altFieldValue($FieldName, $FieldValue); } if ($gmlUseAltFunctions['altFieldNameToUpper']) { $FieldName = altFieldNameToUpper($FieldName); } if ($gmlUseAltFunctions['changeFieldName']) { $FieldName = changeFieldName($FieldName); } $fieldProperties = (array) json_decode($fieldConfArr[$FieldName]->properties); if ($fieldProperties['cartomobilePictureUrl']) { //if ($myrow[$fieldProperties['cartomobilePictureUrl']]) { $FieldValue = getCartoMobilePictureUrl($table, $FieldName, $fieldProperties['cartomobilePictureUrl'], $myrow["fid"]); //} } //$FieldValue = htmlentities($FieldValue); $FieldValue = altUseCdataOnStrings($FieldValue); if ($FieldValue && ($FieldName != "fid" && $FieldName != "FID")) { writeTag("open", $gmlNameSpace, $FieldName, null, True, False); //$FieldType = pg_field_type($result, $i); echo $FieldValue; writeTag("close", $gmlNameSpace, $FieldName, null, False, True); } } elseif ($tableObj->metaData[$FieldName]['type'] == "geometry") { // Check if the geometry field use another name space and element name if (!$gmlGeomFieldName[$table]) { $gmlGeomFieldName[$table] = $FieldName; } if ($gmlNameSpaceGeom) { $tmpNameSpace = $gmlNameSpaceGeom; } else { $tmpNameSpace = $gmlNameSpace; } writeTag("open", $tmpNameSpace, $gmlGeomFieldName[$table], null, True, True); $depth++; if ($useWktToGmlInPHP) { $__geoObj = geometryfactory::createGeometry($myrow[$FieldName], "EPSG:" . $srs); echo $__geoObj->getGML(); unset($__geoObj); } else { echo $myrow[$FieldName]; } $depth--; writeTag("close", $tmpNameSpace, $gmlGeomFieldName[$table], null, True, True); } } $depth--; writeTag("close", $gmlNameSpace, $gmlFeature[$table], null, True, True); $depth--; writeTag("close", "gml", "featureMember", null, True, True); } $totalTime = microtime_float() - $startTime; print "\n<!-- {$totalTime} -->"; $postgisObject->execQuery("ROLLBACK"); }