当前位置: 首页>>代码示例>>PHP>>正文


PHP geoPHP::geosToGeometry方法代码示例

本文整理汇总了PHP中geoPHP::geosToGeometry方法的典型用法代码示例。如果您正苦于以下问题:PHP geoPHP::geosToGeometry方法的具体用法?PHP geoPHP::geosToGeometry怎么用?PHP geoPHP::geosToGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在geoPHP的用法示例。


在下文中一共展示了geoPHP::geosToGeometry方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: centroid

 public function centroid()
 {
     if ($this->isEmpty()) {
         return NULL;
     }
     if ($this->geos()) {
         return geoPHP::geosToGeometry($this->geos()->centroid());
     }
     $exterior_ring = $this->components[0];
     $pts = $exterior_ring->getComponents();
     $c = count($pts);
     if ((int) $c == '0') {
         return NULL;
     }
     $cn = array('x' => '0', 'y' => '0');
     $a = $this->area(TRUE, TRUE);
     // If this is a polygon with no area. Just return the first point.
     if ($a == 0) {
         return $this->exteriorRing()->pointN(1);
     }
     foreach ($pts as $k => $p) {
         $j = ($k + 1) % $c;
         $P = $p->getX() * $pts[$j]->getY() - $p->getY() * $pts[$j]->getX();
         $cn['x'] = $cn['x'] + ($p->getX() + $pts[$j]->getX()) * $P;
         $cn['y'] = $cn['y'] + ($p->getY() + $pts[$j]->getY()) * $P;
     }
     $cn['x'] = $cn['x'] / (6 * $a);
     $cn['y'] = $cn['y'] / (6 * $a);
     $centroid = new Point($cn['x'], $cn['y']);
     return $centroid;
 }
开发者ID:drupdateio,项目名称:gvj,代码行数:31,代码来源:Polygon.class.php

示例2: getBBox

 public function getBBox()
 {
     if ($this->isEmpty()) {
         return NULL;
     }
     if ($this->geos()) {
         $envelope = $this->geos()->envelope();
         if ($envelope->typeName() == 'Point') {
             return geoPHP::geosToGeometry($envelope)->getBBOX();
         }
         $geos_ring = $envelope->exteriorRing();
         return array('maxy' => $geos_ring->pointN(3)->getY(), 'miny' => $geos_ring->pointN(1)->getY(), 'maxx' => $geos_ring->pointN(1)->getX(), 'minx' => $geos_ring->pointN(3)->getX());
     }
     // Go through each component and get the max and min x and y
     $i = 0;
     foreach ($this->components as $component) {
         $component_bbox = $component->getBBox();
         // On the first run through, set the bbox to the component bbox
         if ($i == 0) {
             $maxx = $component_bbox['maxx'];
             $maxy = $component_bbox['maxy'];
             $minx = $component_bbox['minx'];
             $miny = $component_bbox['miny'];
         }
         // Do a check and replace on each boundary, slowly growing the bbox
         $maxx = $component_bbox['maxx'] > $maxx ? $component_bbox['maxx'] : $maxx;
         $maxy = $component_bbox['maxy'] > $maxy ? $component_bbox['maxy'] : $maxy;
         $minx = $component_bbox['minx'] < $minx ? $component_bbox['minx'] : $minx;
         $miny = $component_bbox['miny'] < $miny ? $component_bbox['miny'] : $miny;
         $i++;
     }
     return array('maxy' => $maxy, 'miny' => $miny, 'maxx' => $maxx, 'minx' => $minx);
 }
开发者ID:tijdmedia,项目名称:geophp,代码行数:33,代码来源:Collection.php

示例3: read

 /**
  * Read WKT string into geometry objects
  *
  * @param string $WKT A WKT string
  *
  * @return Geometry|GeometryCollection
  */
 public function read($wkt)
 {
     $wkt = strval($wkt);
     // If geos is installed, then we take a shortcut and let it parse the WKT
     if (geoPHP::geosInstalled()) {
         $reader = new GEOSWKTReader();
         return geoPHP::geosToGeometry($reader->read($wkt));
     }
     $matches = array();
     if (!preg_match($this->regExes['typeStr'], $wkt, $matches)) {
         return null;
     }
     return $this->parse(strtolower($matches[1]), $matches[2]);
 }
开发者ID:happy-code-com,项目名称:PHP5-Shape-File-Parser,代码行数:21,代码来源:WKT.class.php

示例4: 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);
             }
         }
     }
 }
开发者ID:drupdateio,项目名称:gvj,代码行数:48,代码来源:WKT.class.php

示例5: simplify

 public function simplify($tolerance, $preserveTopology = FALSE)
 {
     if ($this->geos()) {
         return geoPHP::geosToGeometry($this->geos()->simplify($tolerance, $preserveTopology));
     }
 }
开发者ID:tijdmedia,项目名称:geophp,代码行数:6,代码来源:Geometry.php


注:本文中的geoPHP::geosToGeometry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。