本文整理汇总了PHP中geoPHP::geometryList方法的典型用法代码示例。如果您正苦于以下问题:PHP geoPHP::geometryList方法的具体用法?PHP geoPHP::geometryList怎么用?PHP geoPHP::geometryList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geoPHP
的用法示例。
在下文中一共展示了geoPHP::geometryList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read
/**
* Read WKT string into geometry objects
*
* @param string $WKT A WKT string
*
* @return Geometry
*/
public function read($wkt)
{
$wkt = trim($wkt);
// If it contains a ';', then it contains additional SRID data
if (strpos($wkt, ';')) {
$parts = explode(';', $wkt);
$wkt = $parts[1];
$eparts = explode('=', $parts[0]);
$srid = $eparts[1];
} else {
$srid = NULL;
}
// If geos is installed, then we take a shortcut and let it parse the WKT
if (geoPHP::geosInstalled()) {
$reader = new GEOSWKTReader();
if ($srid) {
$geom = geoPHP::geosToGeometry($reader->read($wkt));
$geom->setSRID($srid);
return $geom;
} else {
return geoPHP::geosToGeometry($reader->read($wkt));
}
}
$wkt = str_replace(', ', ',', $wkt);
// For each geometry type, check to see if we have a match at the
// beggining of the string. If we do, then parse using that type
foreach (geoPHP::geometryList() as $geom_type) {
$wkt_geom = strtoupper($geom_type);
if (strtoupper(substr($wkt, 0, strlen($wkt_geom))) == $wkt_geom) {
$data_string = $this->getDataString($wkt, $wkt_geom);
$method = 'parse' . $geom_type;
if ($srid) {
$geom = $this->{$method}($data_string);
$geom->setSRID($srid);
return $geom;
} else {
return $this->{$method}($data_string);
}
}
}
}
示例2: parseGeometryCollection
protected function parseGeometryCollection($xml)
{
$components = array();
$geom_types = geoPHP::geometryList();
foreach ($xml->childNodes as $child) {
$nodeName = $child->nodeName == 'linearring' ? 'linestring' : $child->nodeName;
if (array_key_exists($nodeName, $geom_types)) {
$function = 'parse' . $geom_types[$nodeName];
$components[] = $this->{$function}($child);
}
}
return new GeometryCollection($components);
}