• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP geoPHP类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: toInstance

 /**
  * Converts an stdClass object into a Geometry based on its 'type' property
  * Converts an stdClass object into a Geometry, based on its 'type' property
  *
  * @param stdClass $obj Object resulting from json decoding a GeoJSON string
  *
  * @return object Object from class eometry
  */
 private static function toInstance($obj)
 {
     if (is_null($obj)) {
         return null;
     }
     if (!isset($obj->type)) {
         self::checkType($obj);
     }
     if ($obj->type == 'Feature') {
         $instance = self::toGeomInstance($obj->geometry);
     } else {
         if ($obj->type == 'FeatureCollection') {
             $geometries = array();
             foreach ($obj->features as $feature) {
                 $geometries[] = self::toGeomInstance($feature->geometry);
             }
             // Get a geometryCollection or MultiGeometry out of the the provided geometries
             $instance = geoPHP::geometryReduce($geometries);
         } else {
             // It's a geometry
             $instance = self::toGeomInstance($obj);
         }
     }
     return $instance;
 }
开发者ID:happy-code-com,项目名称:PHP5-Shape-File-Parser,代码行数:33,代码来源:GeoJSON.class.php


示例2: geomFromXML

 protected function geomFromXML()
 {
     $geometries = array();
     $geometries = array_merge($geometries, $this->parseWaypoints());
     $geometries = array_merge($geometries, $this->parseTracks());
     $geometries = array_merge($geometries, $this->parseRoutes());
     if (empty($geometries)) {
         throw new Exception("Invalid / Empty GPX");
     }
     return geoPHP::geometryReduce($geometries);
 }
开发者ID:FaddliLWibowo,项目名称:Leaflet-demo,代码行数:11,代码来源:GPX.class.php


示例3: testPlaceholders

 function testPlaceholders()
 {
     foreach (scandir('./input') as $file) {
         $parts = explode('.', $file);
         if ($parts[0]) {
             $format = $parts[1];
             $value = file_get_contents('./input/' . $file);
             $geometry = geoPHP::load($value, $format);
             $placeholders = array(array('name' => 'hasZ'), array('name' => 'is3D'), array('name' => 'isMeasured'), array('name' => 'isEmpty'), array('name' => 'coordinateDimension'), array('name' => 'z'), array('name' => 'm'));
             foreach ($placeholders as $method) {
                 $argument = NULL;
                 $method_name = $method['name'];
                 if (isset($method['argument'])) {
                     $argument = $method['argument'];
                 }
                 switch ($method_name) {
                     case 'm':
                     case 'z':
                         if ($geometry->geometryType() == 'Point') {
                             $this->assertNotNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name);
                         }
                         if ($geometry->geometryType() == 'LineString') {
                             $this->assertNotNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name);
                         }
                         if ($geometry->geometryType() == 'MultiLineString') {
                             $this->assertNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name);
                         }
                         break;
                     case 'coordinateDimension':
                     case 'isEmpty':
                     case 'isMeasured':
                     case 'is3D':
                     case 'hasZ':
                         if ($geometry->geometryType() == 'Point') {
                             $this->assertNotNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name);
                         }
                         if ($geometry->geometryType() == 'LineString') {
                             $this->assertNotNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name);
                         }
                         if ($geometry->geometryType() == 'MultiLineString') {
                             $this->assertNotNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name);
                         }
                         break;
                     default:
                         $this->assertTrue($geometry->{$method_name}($argument), 'Failed on ' . $method_name);
                 }
             }
         }
     }
 }
开发者ID:drupdateio,项目名称:gvj,代码行数:50,代码来源:placeholdersTest.php


示例4: read

 /**
  * Given an object or a string, return a Geometry
  *
  * @param mixed $input The GeoJSON string or object
  *
  * @return object Geometry
  */
 public function read($input)
 {
     if (is_string($input)) {
         $input = json_decode($input);
     }
     if (!is_object($input)) {
         throw new Exception('Invalid JSON');
     }
     if (!is_string($input->type)) {
         throw new Exception('Invalid JSON');
     }
     // Check to see if it's a FeatureCollection
     if ($input->type == 'FeatureCollection') {
         $geoms = array();
         foreach ($input->features as $feature) {
             $geoms[] = $this->read($feature);
         }
         return geoPHP::geometryReduce($geoms);
     }
     // Check to see if it's a Feature
     if ($input->type == 'Feature') {
         return $this->read($input->geometry);
     }
     // It's a geometry - process it
     return $this->objToGeom($input);
 }
开发者ID:tijdmedia,项目名称:geophp,代码行数:33,代码来源:GeoJSON.php


示例5: sql2json

 public function sql2json($SQL, $shape_column, $popup_content = NULL, $label = NULL)
 {
     require_once APPPATH . '../modules/' . $this->cms_module_path('gofrendi.gis.core') . '/classes/geoPHP/geoPHP.inc';
     $map_region = $this->input->post('map_region');
     $map_zoom = $this->input->post('map_zoom');
     $search = array('@map_region', '@map_zoom');
     $replace = array($map_region, $map_zoom);
     $SQL = $this->replace($SQL, $search, $replace);
     $features = array();
     $query = $this->db->query($SQL);
     foreach ($query->result_array() as $row) {
         $geom = geoPHP::load($row[$shape_column], 'wkt');
         $json = $geom->out('json');
         $real_popup_content = "";
         $real_label = "";
         $search = array();
         $replace = array();
         foreach ($row as $column => $value) {
             $search[] = '@' . $column;
             $replace[] = $value;
         }
         if (isset($popup_content)) {
             $real_popup_content = $this->replace($popup_content, $search, $replace);
         }
         if (isset($label)) {
             $real_label = $this->replace($label, $search, $replace);
         }
         $features[] = array("type" => "Feature", "properties" => array("popupContent" => $real_popup_content, "label" => $real_label), "geometry" => json_decode($json));
     }
     $feature_collection = array("type" => "FeatureCollection", "features" => $features);
     return json_encode($feature_collection);
 }
开发者ID:AlvaCorp,项目名称:gis-module,代码行数:32,代码来源:geoformat.php


示例6: 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


示例7: wkb_to_json

function wkb_to_json($wkb)
{
    $geom = geoPHP::load($wkb, 'wkb');
    // echo $geom->out('json');
    // exit();
    return $geom->out('json');
}
开发者ID:Poshan,项目名称:hanssolo,代码行数:7,代码来源:togeojsonopening2.php


示例8: nl_extractWkt

/**
 * Convert a raw coverage value to WKT.
 *
 * @param string $coverage The raw coverage.
 * @return string|null The WKT.
 */
function nl_extractWkt($coverage)
{
    $wkt = null;
    // Get coverage format.
    $format = geoPHP::detectFormat($coverage);
    // Convert / reduce to WKT.
    if (in_array($format, array('wkt', 'kml'))) {
        $wkt = geoPHP::load($coverage)->out('wkt');
    }
    return $wkt;
}
开发者ID:HCDigitalScholarship,项目名称:scattergoodjournals,代码行数:17,代码来源:Coverage.php


示例9: tap_geo_tourml_asset

/**
 * Implements hook_tourml_asset()
 *
 * @param $asset.
 *
 * @return $asset. An altered asset object
 *
 * Use this hook to render assets.  The geofield
 * module stores its data in $asset['wkt'] so
 * we can check against this value to determine
 * that we have a geofield, and act upon it.
 */
function tap_geo_tourml_asset($asset)
{
    // Handle geofield fields
    if (isset($asset['wkt'])) {
        geofield_load_geophp();
        $geometry = geoPHP::load($asset['wkt'], 'wkt');
        if ($geometry) {
            $asset['value'] = $geometry->out('json');
        }
    }
    return $asset;
}
开发者ID:veades,项目名称:tap-cms,代码行数:24,代码来源:tap.api.php


示例10: testInsertGeometry

 protected function testInsertGeometry(Connection $connection)
 {
     $i = 0;
     $connection->beginTransaction();
     $collection = \geoPHP::load(file_get_contents(self::$kml), 'kml');
     $collection->setSRID(4326);
     $connection->insert('test_table', array('id' => $i++, 'name' => 'test_' . $i, 'geometry' => $collection), array('integer', 'string', 'geometry'));
     $connection->commit();
     $data = $connection->fetchAll('SELECT * FROM test_table');
     $this->assertEquals(1, count($data));
     $this->assertEquals(0, $data[0]['id']);
     $this->assertEquals('test_1', $data[0]['name']);
 }
开发者ID:agnetsolutions,项目名称:dbal,代码行数:13,代码来源:AbstractGeometryTypeTest.php


示例11: write

 /**
  * Serialize geometries into a WKT string.
  *
  * @param Geometry $geometry
  *
  * @return string The WKT string representation of the input geometries
  */
 public function write(Geometry $geometry)
 {
     // If geos is installed, then we take a shortcut and let it write the WKT
     if (geoPHP::geosInstalled()) {
         $writer = new GEOSWKTWriter();
         return $writer->write($geometry->geos());
     }
     $type = strtolower($geometry->geometryType());
     if (is_null($data = $this->extract($geometry))) {
         return null;
     }
     return strtoupper($type) . ' (' . $data . ')';
 }
开发者ID:happy-code-com,项目名称:PHP5-Shape-File-Parser,代码行数:20,代码来源:WKT.class.php


示例12: geomFromXML

 protected function geomFromXML()
 {
     $geometries = array();
     $geometries = array_merge($geometries, $this->parsePoints());
     $geometries = array_merge($geometries, $this->parseLines());
     $geometries = array_merge($geometries, $this->parsePolygons());
     $geometries = array_merge($geometries, $this->parseBoxes());
     $geometries = array_merge($geometries, $this->parseCircles());
     if (empty($geometries)) {
         throw new Exception("Invalid / Empty GeoRSS");
     }
     return geoPHP::geometryReduce($geometries);
 }
开发者ID:EarthTeam,项目名称:earthteam.net,代码行数:13,代码来源:GeoRSS.class.php


示例13: testAdapters

 function testAdapters()
 {
     foreach (scandir('./input', SCANDIR_SORT_NONE) as $file) {
         $parts = explode('.', $file);
         if ($parts[0]) {
             $format = $parts[1];
             $input = file_get_contents('./input/' . $file);
             echo "\nloading: " . $file . " for format: " . $format;
             $geometry = geoPHP::load($input, $format);
             // Test adapter output and input. Do a round-trip and re-test
             foreach (geoPHP::getAdapterMap() as $adapter_key => $adapter_class) {
                 if ($adapter_key != 'google_geocode') {
                     //Don't test google geocoder regularily. Uncomment to test
                     $output = $geometry->out($adapter_key);
                     $this->assertNotNull($output, "Empty output on " . $adapter_key);
                     if ($output) {
                         $adapter_loader = new $adapter_class();
                         $test_geom_1 = $adapter_loader->read($output);
                         $test_geom_2 = $adapter_loader->read($test_geom_1->out($adapter_key));
                         $this->assertEquals($test_geom_1->out('wkt'), $test_geom_2->out('wkt'), "Mismatched adapter output in " . $adapter_class . ' (test file: ' . $file . ')');
                     }
                 }
             }
             // Test to make sure adapter work the same wether GEOS is ON or OFF
             // Cannot test methods if GEOS is not intstalled
             if (!geoPHP::geosInstalled()) {
                 return;
             }
             foreach (geoPHP::getAdapterMap() as $adapter_key => $adapter_class) {
                 if ($adapter_key != 'google_geocode') {
                     //Don't test google geocoder regularily. Uncomment to test
                     // Turn GEOS on
                     geoPHP::geosInstalled(TRUE);
                     $output = $geometry->out($adapter_key);
                     if ($output) {
                         $adapter_loader = new $adapter_class();
                         $test_geom_1 = $adapter_loader->read($output);
                         // Turn GEOS off
                         geoPHP::geosInstalled(FALSE);
                         $test_geom_2 = $adapter_loader->read($output);
                         // Turn GEOS back On
                         geoPHP::geosInstalled(TRUE);
                         // Check to make sure a both are the same with geos and without
                         $this->assertEquals($test_geom_1->out('wkt'), $test_geom_2->out('wkt'), "Mismatched adapter output between GEOS and NORM in " . $adapter_class . ' (test file: ' . $file . ')');
                     }
                 }
             }
         }
     }
 }
开发者ID:bekirduz,项目名称:wordpress_4_1_1,代码行数:50,代码来源:adaptersTest.php


示例14: testGeos

 function testGeos()
 {
     if (!geoPHP::geosInstalled()) {
         echo "Skipping GEOS -- not installed";
         return;
     }
     foreach (scandir('./input') as $file) {
         $parts = explode('.', $file);
         if ($parts[0]) {
             $format = $parts[1];
             $value = file_get_contents('./input/' . $file);
             echo "\nloading: " . $file . " for format: " . $format;
             $geometry = geoPHP::load($value, $format);
             $geosMethods = array(array('name' => 'geos'), array('name' => 'setGeos', 'argument' => $geometry->geos()), array('name' => 'PointOnSurface'), array('name' => 'equals', 'argument' => $geometry), array('name' => 'equalsExact', 'argument' => $geometry), array('name' => 'relate', 'argument' => $geometry), array('name' => 'checkValidity'), array('name' => 'isSimple'), array('name' => 'buffer', 'argument' => '10'), array('name' => 'intersection', 'argument' => $geometry), array('name' => 'convexHull'), array('name' => 'difference', 'argument' => $geometry), array('name' => 'symDifference', 'argument' => $geometry), array('name' => 'union', 'argument' => $geometry), array('name' => 'simplify', 'argument' => '0'), array('name' => 'disjoint', 'argument' => $geometry), array('name' => 'touches', 'argument' => $geometry), array('name' => 'intersects', 'argument' => $geometry), array('name' => 'crosses', 'argument' => $geometry), array('name' => 'within', 'argument' => $geometry), array('name' => 'contains', 'argument' => $geometry), array('name' => 'overlaps', 'argument' => $geometry), array('name' => 'covers', 'argument' => $geometry), array('name' => 'coveredBy', 'argument' => $geometry), array('name' => 'distance', 'argument' => $geometry), array('name' => 'hausdorffDistance', 'argument' => $geometry));
             foreach ($geosMethods as $method) {
                 $argument = NULL;
                 $method_name = $method['name'];
                 if (isset($method['argument'])) {
                     $argument = $method['argument'];
                 }
                 switch ($method_name) {
                     case 'isSimple':
                     case 'equals':
                     case 'geos':
                         if ($geometry->geometryType() == 'Point') {
                             $this->assertNotNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name . ' (test file: ' . $file . ')');
                         }
                         if ($geometry->geometryType() == 'LineString') {
                             $this->assertNotNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name . ' (test file: ' . $file . ')');
                         }
                         if ($geometry->geometryType() == 'MultiLineString') {
                             $this->assertNotNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name . ' (test file: ' . $file . ')');
                         }
                         break;
                     default:
                         if ($geometry->geometryType() == 'Point') {
                             $this->assertNotNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name . ' (test file: ' . $file . ')');
                         }
                         if ($geometry->geometryType() == 'LineString') {
                             $this->assertNotNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name . ' (test file: ' . $file . ')');
                         }
                         if ($geometry->geometryType() == 'MultiLineString') {
                             $this->assertNull($geometry->{$method_name}($argument), 'Failed on ' . $method_name . ' (test file: ' . $file . ')');
                         }
                 }
             }
         }
     }
 }
开发者ID:EarthTeam,项目名称:earthteam.net,代码行数:49,代码来源:geosTest.php


示例15: get_bbox

 function get_bbox($gpx_str)
 {
     require_once "geoPHP/geoPHP.inc";
     $geom = geoPHP::load($gpx_str, 'gpx');
     $bbox = $geom->getBBox();
     $tl = $this->is_taiwan($bbox['minx'], $bbox['maxy']);
     $br = $this->is_taiwan($bbox['maxx'], $bbox['miny']);
     if ($tl != $br) {
         $this->taiwan = 0;
     }
     $this->taiwan = $tl;
     // 0 or 1 or 2
     //echo "lon $minlon $maxlon, lat $maxlat $minlat\n"; exit;
     return array($bbox['minx'], $bbox['maxy'], $bbox['maxx'], $bbox['miny']);
 }
开发者ID:KevinStoneCode,项目名称:twmap,代码行数:15,代码来源:svglib.php


示例16: testMethods

 function testMethods()
 {
     $format = 'gpx';
     $value = file_get_contents('./input/20120702.gpx');
     $geometry = geoPHP::load($value, $format);
     $methods = array(array('name' => 'area'), array('name' => 'boundary'), array('name' => 'getBBox'), array('name' => 'centroid'), array('name' => 'length'), array('name' => 'greatCircleLength', 'argument' => 6378137), array('name' => 'haversineLength'), array('name' => 'y'), array('name' => 'x'), array('name' => 'numGeometries'), array('name' => 'geometryN', 'argument' => '1'), array('name' => 'startPoint'), array('name' => 'endPoint'), array('name' => 'isRing'), array('name' => 'isClosed'), array('name' => 'numPoints'), array('name' => 'pointN', 'argument' => '1'), array('name' => 'exteriorRing'), array('name' => 'numInteriorRings'), array('name' => 'interiorRingN', 'argument' => '1'), array('name' => 'dimension'), array('name' => 'geometryType'), array('name' => 'SRID'), array('name' => 'setSRID', 'argument' => '4326'));
     foreach ($methods as $method) {
         $argument = NULL;
         $method_name = $method['name'];
         if (isset($method['argument'])) {
             $argument = $method['argument'];
         }
         $this->_methods_tester($geometry, $method_name, $argument);
     }
 }
开发者ID:EarthTeam,项目名称:earthteam.net,代码行数:15,代码来源:20120702Test.php


示例17: within

 /**
  *
  */
 public function within(Request $request)
 {
     $start = microtime(true);
     if (str_contains($request->path(), 'mongo')) {
         $collection = $this->model->within($request->json('geometry.coordinates'));
         $elapsed = microtime(true) - $start;
     } else {
         $geometry = \geoPHP::load($request->input('geometry'), 'wkt');
         $collection = $this->model->within($geometry->asText('wkt'));
         $elapsed = microtime(true) - $start;
     }
     $logMessage = 'ms to get %s data: %f in %s';
     \Log::debug(sprintf($logMessage, str_contains($request->path(), 'mongo') ? 'Mongo' : 'PostGIS', $elapsed, 'within()'));
     return Response::json(['points' => $collection, 'area' => 0]);
 }
开发者ID:jcorry,项目名称:phpgeo-demo,代码行数:18,代码来源:ActionsController.php


示例18: getBody

 public static function getBody($dataObj)
 {
     // Check if the original data is not GeoJSON
     if (!empty($dataObj->geo_formatted) && $dataObj->geo_formatted) {
         if ($dataObj->source_definition['type'] == 'JSON') {
             return json_encode($dataObj->data);
         } elseif ($dataObj->source_definition['type'] == 'KML') {
             $geom = \geoPHP::load($dataObj->data, 'kml');
             return $geom->out('json');
         }
     }
     // Build the body
     $body = $dataObj->data;
     if (is_object($body)) {
         $body = get_object_vars($dataObj->data);
     }
     $features = array();
     foreach ($body as $dataRow) {
         if (is_object($dataRow)) {
             $dataRow = get_object_vars($dataRow);
         }
         $geo = $dataObj->geo;
         //Guess lat/lon if no geo information was given for this
         if (empty($geo)) {
             if ($lat_long = GeoHelper::findLatLong($dataRow)) {
                 $geo = array("latitude" => $lat_long[0], "longitude" => $lat_long[1]);
             }
         }
         $geometric_ids = self::findGeometry($geo, $dataRow);
         //Prevent geo information being duplicated in properties
         foreach ($geometric_ids[0] as $geometric_id) {
             unset($dataRow[$geometric_id]);
         }
         $feature = array('type' => 'Feature', 'geometry' => $geometric_ids[1], 'properties' => $dataRow);
         $id_prop = @$dataObj->source_definition['map_property'];
         if (!empty($id_prop) && !empty($dataRow[$id_prop])) {
             $feature['id'] = $dataRow[$id_prop];
             unset($dataRow[$id_prop]);
         }
         array_push($features, $feature);
     }
     $result = array('type' => 'FeatureCollection', 'features' => $features);
     // Only add bounding box if we have features and are viewing the entire dataset.
     if (!empty($features) && empty($dataObj->paging)) {
         $result['bbox'] = self::boundingBox($features);
     }
     return json_encode($result);
 }
开发者ID:tdt,项目名称:core,代码行数:48,代码来源:GEOJSONFormatter.php


示例19: nl_getNeatlineFeaturesWkt

/**
 * Return record coverage data from the NeatlineFeatures plugin.
 *
 * @param $record NeatlineRecord The record to get the feature for.
 * @return string|null
 */
function nl_getNeatlineFeaturesWkt($record)
{
    // Halt if Features is not present.
    if (!plugin_is_active('NeatlineFeatures')) {
        return;
    }
    $db = get_db();
    // Get raw coverage.
    $result = $db->fetchOne("SELECT geo FROM `{$db->prefix}neatline_features`\n        WHERE is_map=1 AND item_id=?;", $record->item_id);
    if ($result) {
        // If KML, convert to WKT.
        if (geoPHP::detectFormat($result) == 'kml') {
            $result = nl_kml2wkt(trim($result));
        } else {
            $result = 'GEOMETRYCOLLECTION(' . implode(',', explode('|', $result)) . ')';
        }
    }
    return $result;
}
开发者ID:saden1,项目名称:Neatline,代码行数:25,代码来源:Coverage.php


示例20: test_postgis

function test_postgis($name, $type, $geom, $connection, $format)
{
    global $table;
    // Let's insert into the database using GeomFromWKB
    $insert_string = pg_escape_bytea($geom->out($format));
    pg_query($connection, "INSERT INTO {$table} (name, type, geom) values ('{$name}', '{$type}', GeomFromWKB('{$insert_string}'))");
    // SELECT using asBinary PostGIS
    $result = pg_fetch_all(pg_query($connection, "SELECT asBinary(geom) as geom FROM {$table} WHERE name='{$name}'"));
    foreach ($result as $item) {
        $wkb = pg_unescape_bytea($item['geom']);
        // Make sure to unescape the hex blob
        $geom = geoPHP::load($wkb, $format);
        // We now a full geoPHP Geometry object
    }
    // SELECT and INSERT directly, with no wrapping functions
    $result = pg_fetch_all(pg_query($connection, "SELECT geom as geom FROM {$table} WHERE name='{$name}'"));
    foreach ($result as $item) {
        $wkb = pack('H*', $item['geom']);
        // Unpacking the hex blob
        $geom = geoPHP::load($wkb, $format);
        // We now have a geoPHP Geometry
        // Let's re-insert directly into postGIS
        // We need to unpack the WKB
        $unpacked = unpack('H*', $geom->out($format));
        $insert_string = $unpacked[1];
        pg_query($connection, "INSERT INTO {$table} (name, type, geom) values ('{$name}', '{$type}', '{$insert_string}')");
    }
    // SELECT and INSERT using as EWKT (ST_GeomFromEWKT and ST_AsEWKT)
    $result = pg_fetch_all(pg_query($connection, "SELECT ST_AsEWKT(geom) as geom FROM {$table} WHERE name='{$name}'"));
    foreach ($result as $item) {
        $wkt = $item['geom'];
        // Make sure to unescape the hex blob
        $geom = geoPHP::load($wkt, 'ewkt');
        // We now a full geoPHP Geometry object
        // Let's re-insert directly into postGIS
        $insert_string = $geom->out('ewkt');
        pg_query($connection, "INSERT INTO {$table} (name, type, geom) values ('{$name}', '{$type}', ST_GeomFromEWKT('{$insert_string}'))");
    }
}
开发者ID:drupdateio,项目名称:gvj,代码行数:39,代码来源:postgis.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getID3类代码示例发布时间:2022-05-23
下一篇:
PHP general类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap