當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。