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


PHP geoPHP::getAdapterMap方法代码示例

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


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

示例1: out

 public function out()
 {
     $args = func_get_args();
     $format = array_shift($args);
     $type_map = geoPHP::getAdapterMap();
     $processor_type = $type_map[$format];
     $processor = new $processor_type();
     array_unshift($args, $this);
     $result = call_user_func_array(array($processor, 'write'), $args);
     return $result;
 }
开发者ID:tijdmedia,项目名称:geophp,代码行数:11,代码来源:Geometry.php

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

示例3: load

 static function load()
 {
     $args = func_get_args();
     $data = array_shift($args);
     $type = array_shift($args);
     $type_map = geoPHP::getAdapterMap();
     // Auto-detect type if needed
     if (!$type) {
         // If the user is trying to load a Geometry from a Geometry... Just pass it back
         if (is_object($data)) {
             if ($data instanceof Geometry) {
                 return $data;
             }
         }
         $detected = geoPHP::detectFormat($data);
         if (!$detected) {
             return FALSE;
         }
         $format = explode(':', $detected);
         $type = array_shift($format);
         $args = $format;
     }
     $processor_type = $type_map[$type];
     if (!$processor_type) {
         throw new exception('geoPHP could not find an adapter of type ' . htmlentities($type));
     }
     $processor = new $processor_type();
     // Data is not an array, just pass it normally
     if (!is_array($data)) {
         $result = call_user_func_array(array($processor, "read"), array_merge(array($data), $args));
     } else {
         $geoms = array();
         foreach ($data as $item) {
             $geoms[] = call_user_func_array(array($processor, "read"), array_merge(array($item), $args));
         }
         $result = geoPHP::geometryReduce($geoms);
     }
     return $result;
 }
开发者ID:tijdmedia,项目名称:geophp,代码行数:39,代码来源:GeoPhp.php

示例4: test_adapters

function test_adapters($geometry, $format, $input)
{
    // 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);
            $adapter_loader = new $adapter_class();
            $test_geom_1 = $adapter_loader->read($output);
            $test_geom_2 = $adapter_loader->read($test_geom_1->out($adapter_key));
            // Check to make sure a round-trip results in the same geometry
            if ($test_geom_1->out('wkt') != $test_geom_2->out('wkt')) {
                print "Mismatched adapter output in " . $adapter_class . "\n";
            }
        }
    }
    // 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);
            $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
            if ($test_geom_1->out('wkt') != $test_geom_2->out('wkt')) {
                print "Mismatched adapter output between GEOS and NORM in " . $adapter_class . "\n";
            }
        }
    }
}
开发者ID:leloulight,项目名称:drupal-micah-blog,代码行数:41,代码来源:test.php

示例5: test_geometry

function test_geometry($geometry, $test_adapters = TRUE)
{
    // Test common functions
    $geometry->area();
    $geometry->boundary();
    $geometry->envelope();
    $geometry->getBBox();
    $geometry->centroid();
    $geometry->length();
    $geometry->y();
    $geometry->x();
    $geometry->numGeometries();
    $geometry->geometryN(1);
    $geometry->startPoint();
    $geometry->endPoint();
    $geometry->isRing();
    $geometry->isClosed();
    $geometry->numPoints();
    $geometry->pointN(1);
    $geometry->exteriorRing();
    $geometry->numInteriorRings();
    $geometry->interiorRingN(1);
    $geometry->dimension();
    $geometry->geometryType();
    $geometry->SRID();
    $geometry->setSRID(4326);
    $geometry->getCoordinates();
    $geometry->getGeoInterface();
    // Aliases
    $geometry->getCentroid();
    $geometry->getArea();
    $geometry->getX();
    $geometry->getY();
    $geometry->getGeos();
    $geometry->getGeomType();
    $geometry->getSRID();
    $geometry->asText();
    $geometry->asBinary();
    // GEOS only functions
    $geometry->geos();
    $geometry->setGeos($geometry->geos());
    $geometry->pointOnSurface();
    $geometry->equals($geometry);
    $geometry->equalsExact($geometry);
    $geometry->relate($geometry);
    $geometry->checkValidity();
    $geometry->isSimple();
    $geometry->buffer(10);
    $geometry->intersection($geometry);
    $geometry->convexHull();
    $geometry->difference($geometry);
    $geometry->symDifference($geometry);
    $geometry->union($geometry);
    $geometry->simplify(0);
    // @@TODO: Adjust this once we can deal with empty geometries
    $geometry->disjoint($geometry);
    $geometry->touches($geometry);
    $geometry->intersects($geometry);
    $geometry->crosses($geometry);
    $geometry->within($geometry);
    $geometry->contains($geometry);
    $geometry->overlaps($geometry);
    $geometry->covers($geometry);
    $geometry->coveredBy($geometry);
    $geometry->distance($geometry);
    $geometry->hausdorffDistance($geometry);
    // Place holders
    $geometry->hasZ();
    $geometry->is3D();
    $geometry->isMeasured();
    $geometry->isEmpty();
    $geometry->coordinateDimension();
    $geometry->z();
    $geometry->m();
    // Test adapter output and input. Do a round-trip and re-test
    if ($test_adapters) {
        foreach (geoPHP::getAdapterMap() as $adapter_key => $adapter_class) {
            if ($adapter_key != 'google_geocode') {
                //Don't test google geocoder regularily. Uncomment to test
                $format = $geometry->out($adapter_key);
                $adapter_loader = new $adapter_class();
                $translated_geometry = $adapter_loader->read($format);
                #test_geometry($translated_geometry, FALSE);
            }
        }
    }
}
开发者ID:happy-code-com,项目名称:PHP5-Shape-File-Parser,代码行数:87,代码来源:test.php


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