]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 9 Oct 2016 21:21:45 +0000 (23:21 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 9 Oct 2016 21:21:45 +0000 (23:21 +0200)
CONTRIBUTING.md
lib/Geocode.php
utils/setup.php
website/details.php

index 68355663373496b681669903ed40459b8f941872..d23b33928698eeb97975ac0fe4b188856d8acc81 100644 (file)
@@ -27,9 +27,11 @@ are in process of consolodating the style. The following rules apply:
    * leave out space between a function name and bracket
      but add one between control statement(if, while, etc.) and bracket
 
-This coding style must be applied to any new or changed code. You are also
-welcome to fix the coding style of existing code but please submit separate
-PRs for this.
+The coding style is enforced with PHPCS and can be tested with:
+
+```
+  phpcs --report-width=120 --colors */**.php
+```
 
 ## Testing
 
index 4ed90dc2bb89c2696168c617ff5a604e80bd75c7..83618113ad00e74fcf50640c9384c4f8a9eefc95 100644 (file)
@@ -162,7 +162,7 @@ class Geocode
 
         $this->sViewboxCentreSQL = "ST_SetSRID('LINESTRING(";
         $sSep = '';
-        foreach ($this->aRoutePoints as $aPoint) {
+        foreach ($aRoutePoints as $aPoint) {
             $fPoint = (float)$aPoint;
             $this->sViewboxCentreSQL .= $sSep.$fPoint;
             $sSep = ($sSep == ' ') ? ',' : ' ';
@@ -1553,7 +1553,7 @@ class Geocode
                 // getAddressDetails() is defined in lib.php and uses the SQL function get_addressdata in functions.sql
                 $aResult['address'] = getAddressDetails($this->oDB, $sLanguagePrefArraySQL, $aResult['place_id'], $aResult['country_code'], $aResultPlaceIDs[$aResult['place_id']]);
                 if ($aResult['extra_place'] == 'city' && !isset($aResult['address']['city'])) {
-                    $aResult['address'] = array_merge(array('city' => array_shift(array_values($aResult['address']))), $aResult['address']);
+                    $aResult['address'] = array_merge(array('city' => array_values($aResult['address'])[0]), $aResult['address']);
                 }
             }
 
index 7706b60b36387927611ef9271b110047d7528aa1..9efbcf35553155b2725fc5f0f8bdd9480c341975 100755 (executable)
@@ -124,8 +124,12 @@ if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
     echo 'Postgis version found: '.$fPostgisVersion."\n";
 
     if ($fPostgisVersion < 2.1) {
-        // Function was renamed in 2.1 and throws an annoying deprecation warning
+        // Functions were renamed in 2.1 and throw an annoying deprecation warning
         pgsqlRunScript('ALTER FUNCTION st_line_interpolate_point(geometry, double precision) RENAME TO ST_LineInterpolatePoint');
+        pgsqlRunScript('ALTER FUNCTION ST_Line_Locate_Point(geometry, double precision) RENAME TO ST_LineLocatePoint');
+    }
+    if ($fPostgisVersion < 2.2) {
+        pgsqlRunScript('ALTER FUNCTION ST_Distance_Spheroid(geometry, double precision) RENAME TO ST_DistanceSpheroid');
     }
 
     pgsqlRunScriptFile(CONST_BasePath.'/data/country_name.sql');
@@ -159,7 +163,8 @@ if ($aCMDResult['import-data'] || $aCMDResult['all']) {
 
     $osm2pgsql = CONST_Osm2pgsql_Binary;
     if (!file_exists($osm2pgsql)) {
-        echo "Please download and build osm2pgsql.\nIf it is already installed, check the path in your local settings (settings/local.php) file.\n";
+        echo "Check CONST_Osm2pgsql_Binary in your local settings file.\n";
+        echo "Normally you should not need to set this manually.\n";
         fail("osm2pgsql not found in '$osm2pgsql'");
     }
 
index 61ed4c639e5642e25d82384ccedaac4a6e1cfcb0..1276a0382ad5f97ac20f39be1d3c50ba053cc9a8 100755 (executable)
@@ -66,11 +66,23 @@ $sSQL .= " ST_y(centroid) as lat, ST_x(centroid) as lon,";
 $sSQL .= " case when importance = 0 OR importance IS NULL then 0.75-(rank_search::float/40) else importance end as calculated_importance, ";
 $sSQL .= " ST_AsText(CASE WHEN ST_NPoints(geometry) > 5000 THEN ST_SimplifyPreserveTopology(geometry, 0.0001) ELSE geometry END) as outlinestring";
 $sSQL .= " from placex where place_id = $iPlaceID";
+
 $aPointDetails = chksql($oDB->getRow($sSQL), "Could not get details of place object.");
+
+if (!$aPointDetails) {
+    userError("Unknown place id.");
+}
+
 $aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];
 
 $aClassType = getClassTypesWithImportance();
-$aPointDetails['icon'] = $aClassType[$aPointDetails['class'].':'.$aPointDetails['type']]['icon'];
+
+$sPointClassType = $aPointDetails['class'].':'.$aPointDetails['type'];
+if (isset($aClassType[$sPointClassType]) && $aClassType[$aPointDetails]['icon']) {
+    $aPointDetails['icon'] = $aClassType[$aPointClassType]['icon'];
+} else {
+    $aPointDetails['icon'] = false;
+}
 
 // Get all alternative names (languages, etc)
 $sSQL = "select (each(name)).key,(each(name)).value from placex where place_id = $iPlaceID order by (each(name)).key";