]> git.openstreetmap.org Git - nominatim.git/commitdiff
remove polygon=1 (polypoints) feature
authormarc tobias <mtmail@gmx.net>
Tue, 5 Mar 2019 17:14:25 +0000 (18:14 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 29 Mar 2020 19:58:11 +0000 (21:58 +0200)
lib/Geocode.php
lib/PlaceLookup.php
lib/lib.php
lib/template/search-batch-json.php
lib/template/search-json.php
lib/template/search-xml.php
test/bdd/api/reverse/params.feature
test/bdd/api/reverse/simple.feature
test/bdd/api/search/params.feature
test/bdd/api/search/simple.feature
test/php/Nominatim/LibTest.php

index ab9446e0ebd757837d819a706f250b5a3c1ac408..55dd46e78f44b270811a04d5bf8b2b9baba0c549 100644 (file)
@@ -245,7 +245,6 @@ class Geocode
         }
 
         $this->oPlaceLookup->loadParamArray($oParams, $sForceGeometryType);
-        $this->oPlaceLookup->setIncludePolygonAsPoints($oParams->getBool('polygon'));
         $this->oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', false));
     }
 
index 9f4f143ea23dd2c3f4f7bd488d369671c5ac9bf7..8a1a366678652513e37378e15c36c64d18c0e679 100644 (file)
@@ -15,7 +15,6 @@ class PlaceLookup
     protected $bExtraTags = false;
     protected $bNameDetails = false;
 
-    protected $bIncludePolygonAsPoints = false;
     protected $bIncludePolygonAsText = false;
     protected $bIncludePolygonAsGeoJSON = false;
     protected $bIncludePolygonAsKML = false;
@@ -38,11 +37,6 @@ class PlaceLookup
         return $this->bDeDupe;
     }
 
-    public function setIncludePolygonAsPoints($b = true)
-    {
-        $this->bIncludePolygonAsPoints = $b;
-    }
-
     public function setIncludeAddressDetails($b)
     {
         $this->bAddressDetails = $b;
@@ -61,7 +55,6 @@ class PlaceLookup
 
         if ($sGeomType === null || $sGeomType == 'geojson') {
             $this->bIncludePolygonAsGeoJSON = $oParams->getBool('polygon_geojson');
-            $this->bIncludePolygonAsPoints = false;
         }
 
         if ($oParams->getString('format', '') !== 'geojson') {
@@ -100,7 +93,6 @@ class PlaceLookup
         if ($this->bExtraTags) $aParams['extratags'] = '1';
         if ($this->bNameDetails) $aParams['namedetails'] = '1';
 
-        if ($this->bIncludePolygonAsPoints) $aParams['polygon'] = '1';
         if ($this->bIncludePolygonAsText) $aParams['polygon_text'] = '1';
         if ($this->bIncludePolygonAsGeoJSON) $aParams['polygon_geojson'] = '1';
         if ($this->bIncludePolygonAsKML) $aParams['polygon_kml'] = '1';
@@ -500,7 +492,7 @@ class PlaceLookup
             if ($this->bIncludePolygonAsGeoJSON) $sSQL .= ',ST_AsGeoJSON(geometry) as asgeojson';
             if ($this->bIncludePolygonAsKML) $sSQL .= ',ST_AsKML(geometry) as askml';
             if ($this->bIncludePolygonAsSVG) $sSQL .= ',ST_AsSVG(geometry) as assvg';
-            if ($this->bIncludePolygonAsText || $this->bIncludePolygonAsPoints) $sSQL .= ',ST_AsText(geometry) as astext';
+            if ($this->bIncludePolygonAsText) $sSQL .= ',ST_AsText(geometry) as astext';
             if ($fLonReverse != null && $fLatReverse != null) {
                 $sFrom = ' from (SELECT * , CASE WHEN (class = \'highway\') AND (ST_GeometryType(geometry) = \'ST_LineString\') THEN ';
                 $sFrom .=' ST_ClosestPoint(geometry, ST_SetSRID(ST_Point('.$fLatReverse.','.$fLonReverse.'),4326))';
@@ -527,8 +519,6 @@ class PlaceLookup
                 if ($this->bIncludePolygonAsKML) $aOutlineResult['askml'] = $aPointPolygon['askml'];
                 if ($this->bIncludePolygonAsSVG) $aOutlineResult['assvg'] = $aPointPolygon['assvg'];
                 if ($this->bIncludePolygonAsText) $aOutlineResult['astext'] = $aPointPolygon['astext'];
-                if ($this->bIncludePolygonAsPoints) $aOutlineResult['aPolyPoints'] = geometryText2Points($aPointPolygon['astext'], $fRadius);
-
 
                 if (abs($aPointPolygon['minlat'] - $aPointPolygon['maxlat']) < 0.0000001) {
                     $aPointPolygon['minlat'] = $aPointPolygon['minlat'] - $fRadius;
@@ -551,17 +541,12 @@ class PlaceLookup
 
         // as a fallback we generate a bounding box without knowing the size of the geometry
         if ((!isset($aOutlineResult['aBoundingBox'])) && isset($fLon)) {
-            //
-            if ($this->bIncludePolygonAsPoints) {
-                $sGeometryText = 'POINT('.$fLon.','.$fLat.')';
-                $aOutlineResult['aPolyPoints'] = geometryText2Points($sGeometryText, $fRadius);
-            }
-
-            $aBounds = array();
-            $aBounds['minlat'] = $fLat - $fRadius;
-            $aBounds['maxlat'] = $fLat + $fRadius;
-            $aBounds['minlon'] = $fLon - $fRadius;
-            $aBounds['maxlon'] = $fLon + $fRadius;
+            $aBounds = array(
+                        'minlat' => $fLat - $fRadius,
+                        'maxlat' => $fLat + $fRadius,
+                        'minlon' => $fLon - $fRadius,
+                        'maxlon' => $fLon + $fRadius
+                       );
 
             $aOutlineResult['aBoundingBox'] = array(
                                                (string)$aBounds['minlat'],
index 759c71d7ea735fc7639b9712d4f60e50a3bd3135..a8e6dd70b8e3128e870eb749f3c03733c135dba7 100644 (file)
@@ -165,39 +165,6 @@ function parseLatLon($sQuery)
     return array($sFound, $fQueryLat, $fQueryLon);
 }
 
-
-function geometryText2Points($geometry_as_text, $fRadius)
-{
-    $aPolyPoints = null;
-    if (preg_match('#POLYGON\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
-        //
-        preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
-        //
-    } elseif (preg_match('#LINESTRING\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
-        //
-        preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
-        //
-    } elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) {
-        //
-        preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
-        //
-    } elseif (preg_match('#POINT\\((-?[0-9.]+) (-?[0-9.]+)\\)#', $geometry_as_text, $aMatch)) {
-        //
-        $aPolyPoints = createPointsAroundCenter($aMatch[1], $aMatch[2], $fRadius);
-        //
-    }
-
-    if (isset($aPolyPoints)) {
-        $aResultPoints = array();
-        foreach ($aPolyPoints as $aPoint) {
-            $aResultPoints[] = array($aPoint[1], $aPoint[2]);
-        }
-        return $aResultPoints;
-    }
-
-    return;
-}
-
 function createPointsAroundCenter($fLon, $fLat, $fRadius)
 {
     $iSteps = max(8, min(100, ($fRadius * 40000)^2));
index 40b27a72e9dc9b607f4de61756b9bc335c6ce7e3..c4bc29cb1df4c0d8160003a698c46340cc2020a2 100644 (file)
@@ -25,10 +25,6 @@ foreach ($aBatchResults as $aSearchResults) {
                                       $aPointDetails['aBoundingBox'][2],
                 $aPointDetails['aBoundingBox'][3]
                                      );
-
-            if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons) {
-                $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
-            }
         }
 
         if (isset($aPointDetails['zoom'])) {
index 6108aca4e005582d9446a75ca44737a0ab0ae5c3..4b896d08a6de136207a8e878ff8c2ac73f7e711d 100644 (file)
@@ -15,10 +15,6 @@ foreach ($aSearchResults as $iResNum => $aPointDetails) {
 
     if (isset($aPointDetails['aBoundingBox'])) {
         $aPlace['boundingbox'] = $aPointDetails['aBoundingBox'];
-
-        if (isset($aPointDetails['aPolyPoints'])) {
-            $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
-        }
     }
 
     if (isset($aPointDetails['zoom'])) {
index f67ba33bd2b7e56fa6cdfe2b8444dba502f8dd17..68d985f3cc3111fd6f7aece1cce916efb7bb3f73 100644 (file)
@@ -11,7 +11,6 @@ echo " timestamp='".date(DATE_RFC822)."'";
 echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
 echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'";
 if (isset($aMoreParams['viewbox'])) echo " viewbox='".htmlspecialchars($aMoreParams['viewbox'], ENT_QUOTES)."'";
-echo " polygon='".(isset($aMoreParams['polygon'])?'true':'false')."'";
 if (isset($aMoreParams['exclude_place_ids'])) {
     echo " exclude_place_ids='".htmlspecialchars($aMoreParams['exclude_place_ids'])."'";
 }
@@ -31,12 +30,6 @@ foreach ($aSearchResults as $iResNum => $aResult) {
         echo ' boundingbox="';
         echo join(',', $aResult['aBoundingBox']);
         echo '"';
-
-        if (isset($aResult['aPolyPoints'])) {
-            echo ' polygonpoints=\'';
-            echo json_encode($aResult['aPolyPoints']);
-            echo '\'';
-        }
     }
 
     if (isset($aResult['asgeojson'])) {
index f78c4c6a19b6d8ceb6d73c16957dd5462a3b3beb..2a5821e4c3e1385ed11e391ee93378e2b065107f 100644 (file)
@@ -63,18 +63,6 @@ Feature: Parameters for Reverse API
         | json     | geotext |
         | jsonv2   | geotext |
 
-    Scenario Outline: Reverse Geocoding contains polygon-as-points geometry
-        When sending <format> reverse coordinates 47.165989816710066,9.515774846076965
-          | polygon |
-          | 1 |
-        Then result 0 has not attributes <response_attribute>
-
-    Examples:
-        | format   | response_attribute |
-        | xml      | polygonpoints |
-        | json     | polygonpoints |
-        | jsonv2   | polygonpoints |
-
     Scenario Outline: Reverse Geocoding contains SVG geometry
         When sending <format> reverse coordinates 47.165989816710066,9.515774846076965
           | polygon_svg |
@@ -114,8 +102,8 @@ Feature: Parameters for Reverse API
 
     Scenario Outline: Reverse Geocoding in geojson format contains no non-geojson geometry
         When sending geojson reverse coordinates 47.165989816710066,9.515774846076965
-          | polygon_text | polygon | polygon_svg | polygon_geokml |
-          | 1            | 1       | 1           | 1              |
+          | polygon_text | polygon_svg | polygon_geokml |
+          | 1            | 1           | 1              |
         Then result 0 has not attributes <response_attribute>
 
     Examples:
@@ -124,4 +112,3 @@ Feature: Parameters for Reverse API
         | polygonpoints      |
         | svg                |
         | geokml             |
-
index ccd0becdbb8a837fa62dd64e0b66481ee98ca276..b07989eccf09ca6e66cbd0976f75cc3a4e7a2d72 100644 (file)
@@ -55,8 +55,6 @@ Feature: Simple Reverse Tests
 
     Examples:
      | parameter        | value |
-     | polygon          | 1 |
-     | polygon          | 0 |
      | polygon_text     | 1 |
      | polygon_text     | 0 |
      | polygon_kml      | 1 |
index cdea3f69e92ce51385fdcc47277ef2fd31e4c581..6ba22d03a0c56fbb7294104bf286cde7e79982c8 100644 (file)
@@ -303,18 +303,6 @@ Feature: Search queries
         | json     | geotext |
         | jsonv2   | geotext |
 
-    Scenario Outline: Search result contains polygon-as-points geometry
-        When sending <format> search query "Highmore"
-          | polygon |
-          | 1 |
-        Then result has attributes <response_attribute>
-
-    Examples:
-        | format   | response_attribute |
-        | xml      | polygonpoints |
-        | json     | polygonpoints |
-        | jsonv2   | polygonpoints |
-
     Scenario Outline: Search result contains SVG geometry
         When sending <format> search query "Highmore"
           | polygon_svg |
@@ -354,8 +342,8 @@ Feature: Search queries
 
     Scenario Outline: Search result in geojson format contains no non-geojson geometry
         When sending geojson search query "Highmore"
-          | polygon_text | polygon | polygon_svg | polygon_geokml |
-          | 1            | 1       | 1           | 1              |
+          | polygon_text | polygon_svg | polygon_geokml |
+          | 1            | 1           | 1              |
         Then result 0 has not attributes <response_attribute>
 
     Examples:
index c12635972dd29a48afb0cd9ed8f72b871da0334a..fe2d684e8ee285b0bbf72b5bc913cc7bd028c4a3 100644 (file)
@@ -36,8 +36,6 @@ Feature: Simple Tests
      | parameter        | value |
      | addressdetails   | 1 |
      | addressdetails   | 0 |
-     | polygon          | 1 |
-     | polygon          | 0 |
      | polygon_text     | 1 |
      | polygon_text     | 0 |
      | polygon_kml      | 1 |
@@ -98,7 +96,6 @@ Feature: Simple Tests
         Then result header contains
           | attr        | value |
           | querystring | xnznxvcx |
-          | polygon     | false |
           | more_url    | .*q=xnznxvcx.*format=xml |
 
     Scenario: Empty XML search with special XML characters
@@ -106,7 +103,6 @@ Feature: Simple Tests
         Then result header contains
           | attr        | value |
           | querystring | xfdghn&zxn"xvbyx<vxx>cssdex |
-          | polygon     | false |
           | more_url    | .*q=xfdghn%26zxn%22xvbyx%3Cvxx%3Ecssdex.*format=xml |
 
     Scenario: Empty XML search with viewbox
@@ -116,7 +112,6 @@ Feature: Simple Tests
         Then result header contains
           | attr        | value |
           | querystring | xnznxvcx |
-          | polygon     | false |
           | viewbox     | 12,33,77,45.13 |
 
     Scenario: Empty XML search with viewboxlbrt
@@ -126,7 +121,6 @@ Feature: Simple Tests
         Then result header contains
           | attr        | value |
           | querystring | xnznxvcx |
-          | polygon     | false |
           | viewbox     | 12,34.13,77,45 |
 
     Scenario: Empty XML search with viewboxlbrt and viewbox
@@ -136,29 +130,8 @@ Feature: Simple Tests
         Then result header contains
           | attr        | value |
           | querystring | pub |
-          | polygon     | false |
           | viewbox     | 12,33,77,45.13 |
 
-    Scenario Outline: Empty XML search with polygon values
-        When sending xml search query "xnznxvcx"
-          | param   | value |
-          | polygon | <polyval> |
-        Then result header contains
-          | attr        | value |
-          | polygon     | <result> |
-
-    Examples:
-     | result | polyval |
-     | false  | 0 |
-     | true   | 1 |
-     | true   | True |
-     | true   | true |
-     | true   | false |
-     | true   | FALSE |
-     | true   | yes |
-     | true   | no |
-     | true   | '; delete from foobar; select ' |
-
     Scenario: Empty XML search with exluded place ids
         When sending xml search query "jghrleoxsbwjer"
           | exclude_place_ids |
index a80ef73b6fd53f65eca9cfc0d062432f3fa7a9cd..dca2107d7bc07771bf8e969a5094dc10132b2a75 100644 (file)
@@ -35,55 +35,6 @@ class LibTest extends \PHPUnit\Framework\TestCase
         );
     }
 
-
-    public function testGeometryText2Points()
-    {
-        $fRadius = 1;
-        // invalid value
-        $this->assertEquals(
-            null,
-            geometryText2Points('', $fRadius)
-        );
-
-        // POINT
-        $aPoints = geometryText2Points('POINT(10 20)', $fRadius);
-        $this->assertEquals(
-            101,
-            count($aPoints)
-        );
-        $this->assertEquals(
-            array(
-             array(10, 21),
-             array(10.062790519529, 20.998026728428),
-             array(10.125333233564, 20.992114701314)
-            ),
-            array_splice($aPoints, 0, 3)
-        );
-
-        // POLYGON
-        $this->assertEquals(
-            array(
-             array('30', '10'),
-             array('40', '40'),
-             array('20', '40'),
-             array('10', '20'),
-             array('30', '10')
-            ),
-            geometryText2Points('POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))', $fRadius)
-        );
-
-        // MULTIPOLYGON
-        $this->assertEquals(
-            array(
-             array('30', '20'), // first polygon only
-             array('45', '40'),
-             array('10', '40'),
-             array('30', '20'),
-            ),
-            geometryText2Points('MULTIPOLYGON(((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))', $fRadius)
-        );
-    }
-
     public function testParseLatLon()
     {
         // no coordinates expected