]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 26 Apr 2018 20:29:54 +0000 (22:29 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 26 Apr 2018 20:29:54 +0000 (22:29 +0200)
15 files changed:
lib/cmd.php
nominatim/CMakeLists.txt
nominatim/postgresql.h
phpcs.xml
sql/functions.sql
sql/indices.src.sql
sql/partition-functions.src.sql
sql/partition-tables.src.sql
test/bdd/db/import/search_name.feature
test/bdd/steps/db_ops.py
test/php/Nominatim/LibTest.php
test/php/Nominatim/ParameterParserTest.php
vagrant/install-on-travis-ci.sh
website/lookup.php
website/reverse.php

index 1edf5dfd5c53d077b03453cfcf5192b0ac54b4a8..28d56f2e0346eabbc9668e6bca2201704f57e4dc 100644 (file)
@@ -134,7 +134,7 @@ function info($sMsg)
     echo date('Y-m-d H:i:s == ').$sMsg."\n";
 }
 
-$aWarnings = [];
+$aWarnings = array();
 
 
 function warn($sMsg)
index 726ec4cc3007a1d8918bf2994b505e285eb9bcae..b391a342d752ca061c46e606a96809c70996a2f4 100644 (file)
@@ -1,12 +1,12 @@
 add_executable(nominatim export.c geometry.cpp import.c index.c input.c nominatim.c postgresql.c sprompt.c)
-include(CheckIncludeFile)
-CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H)
-CHECK_INCLUDE_FILE(sys/endian.h HAVE_SYS_ENDIAN_H)
-if(HAVE_BYTESWAP_H)
-  target_compile_definitions(nominatim PRIVATE HAVE_BYTESWAP_H)
-endif(HAVE_BYTESWAP_H)
-if(HAVE_SYS_ENDIAN_H)
-  target_compile_definitions(nominatim PRIVATE HAVE_SYS_ENDIAN_H)
-endif(HAVE_SYS_ENDIAN_H)
+
+CHECK_SYMBOL_EXISTS(bswap_32 "byteswap.h" HAVE_BYTESWAP)
+CHECK_SYMBOL_EXISTS(bswap32 "sys/endian.h" HAVE_SYS_ENDIAN)
+
+target_compile_definitions(nominatim
+    PRIVATE HAVE_BYTESWAP=$<BOOL:${HAVE_BYTESWAP}>
+    PRIVATE HAVE_SYS_ENDIAN=$<BOOL:${HAVE_SYS_ENDIAN}>
+)
+
 target_link_libraries(nominatim ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PostgreSQL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
 
index 7050fca4ed7302399097b4bbf262b32b38a2e5ec..f30e7308113b09cd85b5d9752849f829c687749e 100644 (file)
@@ -7,20 +7,32 @@
 #define PG_OID_INT8                    20
 #define PG_OID_INT4                    23
 
-#if defined(HAVE_BYTESWAP_H)
+#if HAVE_BYTESWAP
 #include <byteswap.h>
-#elif defined(HAVE_SYS_ENDIAN_H)
+#define PG_BSWAP32(x) bswap_32(x)
+#define PG_BSWAP64(x) bswap_64(x)
+#elif HAVE_SYS_ENDIAN
 #include <sys/endian.h>
+#define PG_BSWAP32(x) bswap32(x)
+#define PG_BSWAP64(x) bswap64(x)
+#else
+#error "No appropriate byteswap found for your system."
 #endif
 
-#if __BYTE_ORDER == __BIG_ENDIAN
-#define PGint16(x)     (x)
+#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+#define PGint32(x)     (x)
+#define PGint64(x)     (x)
+#elif defined(__BYTE_ORDER__) &&  (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+#define PGint32(x)     PG_BSWAP32(x)
+#define PGint64(x)     PG_BSWAP64(x)
+#elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)
 #define PGint32(x)     (x)
 #define PGint64(x)     (x)
+#elif defined(_BYTE_ORDER) &&  (_BYTE_ORDER == _LITTLE_ENDIAN)
+#define PGint32(x)     PG_BSWAP32(x)
+#define PGint64(x)     PG_BSWAP64(x)
 #else
-#define PGint16(x)     __bswap_16 (x)
-#define PGint32(x)     __bswap_32 (x)
-#define PGint64(x)     __bswap_64 (x)
+#error "Cannot determine byte order."
 #endif
 
 const char *build_conninfo(const char *db, const char *username, const char *password, const char *host, const char *port);
index 6b4abc392a8279971f43e6a382708f6b7e6c2aed..09360731510b48b7ecdf8ebe8827897029b5a3db 100644 (file)
--- a/phpcs.xml
+++ b/phpcs.xml
     <severity>0</severity>
   </rule>
 
+  <!-- array() instead of [] for initialisation -->
+  <rule ref="Generic.Arrays.DisallowShortArraySyntax.Found" />
 
 
 
index 396487b1ae1a1c3c93f5236c009324bd71a67252..305365d1b612878d292df21f7d436f02ce3c808f 100644 (file)
@@ -1234,6 +1234,7 @@ DECLARE
   relation_members TEXT[];
   relMember RECORD;
   linkedplacex RECORD;
+  addr_item RECORD;
   search_diameter FLOAT;
   search_prevdiameter FLOAT;
   search_maxrank INTEGER;
@@ -1766,44 +1767,43 @@ BEGIN
   parent_place_id_rank = 0;
 
 
-  -- convert isin to array of tokenids
+  -- convert address store to array of tokenids
   --DEBUG: RAISE WARNING 'Starting address search';
   isin_tokens := '{}'::int[];
   IF NEW.address IS NOT NULL THEN
-    isin := avals(NEW.address);
-    IF array_upper(isin, 1) IS NOT NULL THEN
-      FOR i IN 1..array_upper(isin, 1) LOOP
-        -- TODO further split terms with comma and semicolon
-        address_street_word_id := get_name_id(make_standard_name(isin[i]));
+    FOR addr_item IN SELECT * FROM each(NEW.address)
+    LOOP
+      IF addr_item.key IN ('city', 'tiger:county', 'state', 'suburb', 'province', 'district', 'region', 'county', 'municipality', 'hamlet', 'village', 'subdistrict', 'town', 'neighbourhood', 'quarter', 'parish') THEN
+        address_street_word_id := get_name_id(make_standard_name(addr_item.value));
         IF address_street_word_id IS NOT NULL AND NOT(ARRAY[address_street_word_id] <@ isin_tokens) THEN
-          nameaddress_vector := array_merge(nameaddress_vector, ARRAY[address_street_word_id]);
           isin_tokens := isin_tokens || address_street_word_id;
         END IF;
-
-        -- merge word into address vector
-        address_street_word_id := get_word_id(make_standard_name(isin[i]));
+        address_street_word_id := get_word_id(make_standard_name(addr_item.value));
         IF address_street_word_id IS NOT NULL THEN
           nameaddress_vector := array_merge(nameaddress_vector, ARRAY[address_street_word_id]);
         END IF;
-      END LOOP;
-    END IF;
-  END IF;
+      END IF;
+      IF addr_item.key = 'is_in' THEN
+        -- is_in items need splitting
+        isin := regexp_split_to_array(addr_item.value, E'[;,]');
+        IF array_upper(isin, 1) IS NOT NULL THEN
+          FOR i IN 1..array_upper(isin, 1) LOOP
+            address_street_word_id := get_name_id(make_standard_name(isin[i]));
+            IF address_street_word_id IS NOT NULL AND NOT(ARRAY[address_street_word_id] <@ isin_tokens) THEN
+              isin_tokens := isin_tokens || address_street_word_id;
+            END IF;
 
-  -- %NOTIGERDATA% IF 0 THEN
-  -- for the USA we have an additional address table.  Merge in zip codes from there too
-  IF NEW.rank_search = 26 AND NEW.country_code = 'us' THEN
-    FOR location IN SELECT distinct postcode from location_property_tiger where parent_place_id = NEW.place_id LOOP
-      address_street_word_id := get_name_id(make_standard_name(location.postcode));
-      nameaddress_vector := array_merge(nameaddress_vector, ARRAY[address_street_word_id]);
-      isin_tokens := isin_tokens || address_street_word_id;
-
-      -- also merge in the single word version
-      address_street_word_id := get_word_id(make_standard_name(location.postcode));
-      nameaddress_vector := array_merge(nameaddress_vector, ARRAY[address_street_word_id]);
+            -- merge word into address vector
+            address_street_word_id := get_word_id(make_standard_name(isin[i]));
+            IF address_street_word_id IS NOT NULL THEN
+              nameaddress_vector := array_merge(nameaddress_vector, ARRAY[address_street_word_id]);
+            END IF;
+          END LOOP;
+        END IF;
+      END IF;
     END LOOP;
   END IF;
-  --DEBUG: RAISE WARNING 'Tiger postcodes collected';
-  -- %NOTIGERDATA% END IF;
+  nameaddress_vector := array_merge(nameaddress_vector, isin_tokens);
 
 -- RAISE WARNING 'ISIN: %', isin_tokens;
 
@@ -1884,40 +1884,6 @@ BEGIN
   END LOOP;
   --DEBUG: RAISE WARNING 'address computed';
 
-  -- try using the isin value to find parent places
-  IF array_upper(isin_tokens, 1) IS NOT NULL THEN
-    FOR i IN 1..array_upper(isin_tokens, 1) LOOP
---RAISE WARNING '  getNearestNamedFeature: % % % %',NEW.partition, place_centroid, search_maxrank, isin_tokens[i];
-      IF NOT ARRAY[isin_tokens[i]] <@ nameaddress_vector THEN
-
-        FOR location IN SELECT * from getNearestNamedFeature(NEW.partition, place_centroid, search_maxrank, isin_tokens[i]) LOOP
-
---RAISE WARNING '  ISIN: %',location;
-
-          IF location.rank_search > 4 THEN
-              nameaddress_vector := array_merge(nameaddress_vector, location.keywords::integer[]);
-              INSERT INTO place_addressline (place_id, address_place_id, fromarea, isaddress, distance, cached_rank_address)
-                VALUES (NEW.place_id, location.place_id, false, NOT address_havelevel[location.rank_address], location.distance, location.rank_address);
-              IF NEW.postcode is null AND location.postcode is not null
-                 AND NOT address_havelevel[location.rank_address] THEN
-                NEW.postcode := location.postcode;
-              END IF;
-
-              address_havelevel[location.rank_address] := true;
-
-              IF location.rank_address > parent_place_id_rank THEN
-                NEW.parent_place_id = location.place_id;
-                parent_place_id_rank = location.rank_address;
-              END IF;
-          END IF;
-        END LOOP;
-
-      END IF;
-
-    END LOOP;
-  END IF;
-  --DEBUG: RAISE WARNING 'isin tokens processed';
-
   -- for long ways we should add search terms for the entire length
   IF st_length(NEW.geometry) > 0.05 THEN
 
index cf5c4bc1779601e5324950c2412e8adefbaa4139..61af89002b81762be8835b7b7170e73bcdfae880 100644 (file)
@@ -19,8 +19,6 @@ CREATE INDEX idx_location_area_country_place_id ON location_area_country USING B
 
 CREATE INDEX idx_osmline_parent_place_id ON location_property_osmline USING BTREE (parent_place_id) {ts:search-index};
 
-CREATE INDEX idx_search_name_country_centroid ON search_name_country USING GIST (centroid) {ts:address-index};
-
 DROP INDEX IF EXISTS place_id_idx;
 CREATE UNIQUE INDEX idx_place_osm_unique on place using btree(osm_id,osm_type,class,type) {ts:address-index};
 
index 32b5f0a17f3c7f5396786b1da82e01f2822759bf..cc11cf960ace6d373c1892eb5cfaddb6e33733e4 100644 (file)
@@ -84,38 +84,6 @@ END
 $$
 LANGUAGE plpgsql;
 
-create or replace function getNearestNamedFeature(in_partition INTEGER, point GEOMETRY, maxrank INTEGER, isin_token INTEGER) RETURNS setof nearfeature AS $$
-DECLARE
-  r nearfeature%rowtype;
-BEGIN
-
--- start
-  IF in_partition = -partition- THEN
-    FOR r IN 
-      SELECT place_id, name_vector, address_rank, search_rank,
-          ST_Distance(centroid, point) as distance, null as isguess
-          FROM search_name_-partition-
-          WHERE name_vector @> ARRAY[isin_token]
-          AND search_rank < maxrank
-      UNION ALL
-      SELECT place_id, name_vector, address_rank, search_rank,
-          ST_Distance(centroid, point) as distance, null as isguess
-          FROM search_name_country
-          WHERE name_vector @> ARRAY[isin_token]
-          AND search_rank < maxrank
-      ORDER BY distance ASC limit 1
-    LOOP
-      RETURN NEXT r;
-    END LOOP;
-    RETURN;
-  END IF;
--- end
-
-  RAISE EXCEPTION 'Unknown partition %', in_partition;
-END
-$$
-LANGUAGE plpgsql;
-
 create or replace function getNearestNamedRoadFeature(in_partition INTEGER, point GEOMETRY, isin_token INTEGER[]) 
   RETURNS setof nearfeature AS $$
 DECLARE
@@ -185,15 +153,6 @@ BEGIN
   INSERT INTO search_name (place_id, search_rank, address_rank, importance, country_code, name_vector, nameaddress_vector, centroid)
     values (in_place_id, in_rank_search, in_rank_address, in_importance, in_country_code, in_name_vector, in_nameaddress_vector, in_centroid);
 
-  IF in_rank_search <= 4 THEN
-    DELETE FROM search_name_country WHERE place_id = in_place_id;
-    IF in_rank_address > 0 THEN
-      INSERT INTO search_name_country (place_id, search_rank, address_rank, name_vector, centroid)
-        values (in_place_id, in_rank_search, in_rank_address, in_name_vector, in_geometry);
-    END IF;
-    RETURN TRUE;
-  END IF;
-
 -- start
   IF in_partition = -partition- THEN
     DELETE FROM search_name_-partition- values WHERE place_id = in_place_id;
@@ -216,7 +175,6 @@ DECLARE
 BEGIN
 
   DELETE from search_name WHERE place_id = in_place_id;
-  DELETE from search_name_country WHERE place_id = in_place_id;
 
 -- start
   IF in_partition = -partition- THEN
index d8f02e10825a0c851b80cbee6b100e333657b889..61ed52814b63dbaa6206570fad93e88da867666a 100644 (file)
@@ -38,10 +38,6 @@ CREATE TABLE search_name_blank (
 CREATE TABLE location_area_country () INHERITS (location_area_large) {ts:address-data};
 CREATE INDEX idx_location_area_country_geometry ON location_area_country USING GIST (geometry) {ts:address-index};
 
-CREATE TABLE search_name_country () INHERITS (search_name_blank) {ts:address-data};
-CREATE INDEX idx_search_name_country_place_id ON search_name_country USING BTREE (place_id) {ts:address-index};
-CREATE INDEX idx_search_name_country_name_vector ON search_name_country USING GIN (name_vector) WITH (fastupdate = off) {ts:address-index};
-
 -- start
 CREATE TABLE location_area_large_-partition- () INHERITS (location_area_large) {ts:address-data};
 CREATE INDEX idx_location_area_large_-partition-_place_id ON location_area_large_-partition- USING BTREE (place_id) {ts:address-index};
index 86bdea9bfd78133291f376d44251000039a1c7f0..cf3ce4dd266a27d2eaa8888e630324ca3e2d55f2 100644 (file)
@@ -23,3 +23,57 @@ Feature: Creation of search terms
         Then search_name contains
          | object | name_vector | nameaddress_vector |
          | N1     | foo         | the road |
+
+    Scenario: Some addr: tags are added to address when the name exists
+        Given the scene roads-with-pois
+        And the places
+         | osm | class   | type        | name     | geometry |
+         | N1  | place   | state       | new york | 80 80 |
+         | N1  | place   | city        | bonn     | 81 81 |
+         | N1  | place   | suburb      | smalltown| 80 81 |
+        And the named places
+         | osm | class   | type    | addr+city | addr+state | addr+suburb | geometry |
+         | W1  | highway | service | bonn      | New York   | Smalltown   | :w-north |
+        When importing
+        Then search_name contains
+         | object | nameaddress_vector |
+         | W1     | bonn, new york, smalltown |
+
+    Scenario: A known addr:* tag is not added if the name is unknown
+        Given the scene roads-with-pois
+        And the places
+         | osm | class   | type        | name | addr+city | geometry |
+         | W1  | highway | residential | Road | Nandu     | :w-north |
+        When importing
+        Then search_name contains not
+         | object | nameaddress_vector |
+         | W1     | nandu |
+
+    Scenario: addr:postcode is not added to the address terms
+        Given the scene roads-with-pois
+        And the places
+         | osm | class   | type        | name+ref  | geometry |
+         | N1  | place   | state       | 12345     | 80 80 |
+        And the named places
+         | osm | class   | type        | addr+postcode | geometry |
+         | W1  | highway | residential | 12345 | :w-north |
+        When importing
+        Then search_name contains not
+         | object | nameaddress_vector |
+         | W1     | 12345 |
+
+    Scenario: is_in is split and added to the address search terms
+        Given the scene roads-with-pois
+        And the places
+         | osm | class   | type        | name     | geometry |
+         | N1  | place   | state       | new york | 80 80 |
+         | N1  | place   | city        | bonn     | 81 81 |
+         | N1  | place   | suburb      | smalltown| 80 81 |
+        And the named places
+         | osm | class   | type    | addr+is_in                | geometry |
+         | W1  | highway | service | bonn, New York, Smalltown | :w-north |
+        When importing
+        Then search_name contains
+         | object | nameaddress_vector |
+         | W1     | bonn, new york, smalltown |
+
index 87babdad88158a1f42cb26f136d5957bfc4ad0b9..80f922222c0018c7e99c69e8064990883c51b69c 100644 (file)
@@ -427,8 +427,8 @@ def check_placex_contents(context, exact):
 
     context.db.commit()
 
-@then("search_name contains")
-def check_search_name_contents(context):
+@then("search_name contains(?P<exclude> not)?")
+def check_search_name_contents(context, exclude):
     cur = context.db.cursor(cursor_factory=psycopg2.extras.DictCursor)
 
     for row in context.table:
@@ -446,11 +446,16 @@ def check_search_name_contents(context):
                                       FROM word, (SELECT unnest(%s) as term) t
                                       WHERE word_token = make_standard_name(t.term)""",
                                    (terms,))
-                    ok_(subcur.rowcount >= len(terms),
-                        "No word entry found for " + row[h])
+                    if not exclude:
+                        ok_(subcur.rowcount >= len(terms),
+                            "No word entry found for " + row[h])
                     for wid in subcur:
-                        assert_in(wid[0], res[h],
-                                  "Missing term for %s/%s: %s" % (pid, h, wid[1]))
+                        if exclude:
+                            assert_not_in(wid[0], res[h],
+                                          "Found term for %s/%s: %s" % (pid, h, wid[1]))
+                        else:
+                            assert_in(wid[0], res[h],
+                                      "Missing term for %s/%s: %s" % (pid, h, wid[1]))
                 else:
                     assert_db_column(res, h, row[h], context)
 
index ee6f94f237e83e0c09a66c760b6e476437b2c482..533188adea7c98e612a1d645e68eccb8c1864cc2 100644 (file)
@@ -70,9 +70,9 @@ class LibTest extends \PHPUnit_Framework_TestCase
         );
         $this->assertEquals(
             array(
-             ['', 0, 2],
-             ['', 0.12558103905863, 1.9960534568565],
-             ['', 0.25066646712861, 1.984229402629]
+             array('', 0, 2),
+             array('', 0.12558103905863, 1.9960534568565),
+             array('', 0.25066646712861, 1.984229402629)
             ),
             array_splice($aPoints, 0, 3)
         );
@@ -96,9 +96,9 @@ class LibTest extends \PHPUnit_Framework_TestCase
         );
         $this->assertEquals(
             array(
-             [10, 21],
-             [10.062790519529, 20.998026728428],
-             [10.125333233564, 20.992114701314]
+             array(10, 21),
+             array(10.062790519529, 20.998026728428),
+             array(10.125333233564, 20.992114701314)
             ),
             array_splice($aPoints, 0, 3)
         );
@@ -106,11 +106,11 @@ class LibTest extends \PHPUnit_Framework_TestCase
         // POLYGON
         $this->assertEquals(
             array(
-             ['30', '10'],
-             ['40', '40'],
-             ['20', '40'],
-             ['10', '20'],
-             ['30', '10']
+             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)
         );
@@ -118,10 +118,10 @@ class LibTest extends \PHPUnit_Framework_TestCase
         // MULTIPOLYGON
         $this->assertEquals(
             array(
-             ['30', '20'], // first polygon only
-             ['45', '40'],
-             ['10', '40'],
-             ['30', '20'],
+             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)
         );
@@ -190,15 +190,15 @@ class LibTest extends \PHPUnit_Framework_TestCase
 
     private function closestHouseNumberEvenOddOther($startnumber, $endnumber, $fraction, $aExpected)
     {
-        foreach (['even', 'odd', 'other'] as $itype) {
+        foreach (array('even', 'odd', 'other') as $itype) {
             $this->assertEquals(
                 $aExpected[$itype],
-                closestHouseNumber([
+                closestHouseNumber(array(
                                     'startnumber' => $startnumber,
                                     'endnumber' => $endnumber,
                                     'fraction' => $fraction,
                                     'interpolationtype' => $itype
-                                   ]),
+                                   )),
                 "$startnumber => $endnumber, $fraction, $itype"
             );
         }
@@ -206,14 +206,14 @@ class LibTest extends \PHPUnit_Framework_TestCase
 
     public function testClosestHouseNumber()
     {
-        $this->closestHouseNumberEvenOddOther(50, 100, 0.5, ['even' => 76, 'odd' => 75, 'other' => 75]);
+        $this->closestHouseNumberEvenOddOther(50, 100, 0.5, array('even' => 76, 'odd' => 75, 'other' => 75));
         // upper bound
-        $this->closestHouseNumberEvenOddOther(50, 100, 1.5, ['even' => 100, 'odd' => 100, 'other' => 100]);
+        $this->closestHouseNumberEvenOddOther(50, 100, 1.5, array('even' => 100, 'odd' => 100, 'other' => 100));
         // lower bound
-        $this->closestHouseNumberEvenOddOther(50, 100, -0.5, ['even' => 50, 'odd' => 50, 'other' => 50]);
+        $this->closestHouseNumberEvenOddOther(50, 100, -0.5, array('even' => 50, 'odd' => 50, 'other' => 50));
         // fraction 0
-        $this->closestHouseNumberEvenOddOther(50, 100, 0, ['even' => 50, 'odd' => 51, 'other' => 50]);
+        $this->closestHouseNumberEvenOddOther(50, 100, 0, array('even' => 50, 'odd' => 51, 'other' => 50));
         // start == end
-        $this->closestHouseNumberEvenOddOther(50, 50, 0.5, ['even' => 50, 'odd' => 50, 'other' => 50]);
+        $this->closestHouseNumberEvenOddOther(50, 50, 0.5, array('even' => 50, 'odd' => 50, 'other' => 50));
     }
 }
index 4265cffbb6f068d472f3e941237e4677582cad36..0cbc60c545c5494b74d05493073ecbdc1b8d5008 100644 (file)
@@ -18,13 +18,13 @@ class ParameterParserTest extends \PHPUnit_Framework_TestCase
 
     public function testGetBool()
     {
-        $oParams = new ParameterParser([
+        $oParams = new ParameterParser(array(
                                         'bool1' => '1',
                                         'bool2' => '0',
                                         'bool3' => 'true',
                                         'bool4' => 'false',
                                         'bool5' => ''
-                                       ]);
+                                       ));
 
         $this->assertSame(false, $oParams->getBool('non-exists'));
         $this->assertSame(true, $oParams->getBool('non-exists', true));
@@ -38,11 +38,11 @@ class ParameterParserTest extends \PHPUnit_Framework_TestCase
 
     public function testGetInt()
     {
-        $oParams = new ParameterParser([
+        $oParams = new ParameterParser(array(
                                         'int1' => '5',
                                         'int2' => '-1',
                                         'int3' => 0
-                                       ]);
+                                       ));
 
         $this->assertSame(false, $oParams->getInt('non-exists'));
         $this->assertSame(999, $oParams->getInt('non-exists', 999));
@@ -56,25 +56,25 @@ class ParameterParserTest extends \PHPUnit_Framework_TestCase
     public function testGetIntWithNonNumber()
     {
         $this->setExpectedException(Exception::class, "Integer number expected for parameter 'int4'");
-        (new ParameterParser(['int4' => 'a']))->getInt('int4');
+        (new ParameterParser(array('int4' => 'a')))->getInt('int4');
     }
 
 
     public function testGetIntWithEmpytString()
     {
         $this->setExpectedException(Exception::class, "Integer number expected for parameter 'int5'");
-        (new ParameterParser(['int5' => '']))->getInt('int5');
+        (new ParameterParser(array('int5' => '')))->getInt('int5');
     }
 
 
     public function testGetFloat()
     {
 
-        $oParams = new ParameterParser([
+        $oParams = new ParameterParser(array(
                                         'float1' => '1.0',
                                         'float2' => '-5',
                                         'float3' => 0
-                                       ]);
+                                       ));
 
         $this->assertSame(false, $oParams->getFloat('non-exists'));
         $this->assertSame(999, $oParams->getFloat('non-exists', 999));
@@ -86,30 +86,30 @@ class ParameterParserTest extends \PHPUnit_Framework_TestCase
     public function testGetFloatWithEmptyString()
     {
         $this->setExpectedException(Exception::class, "Floating-point number expected for parameter 'float4'");
-        (new ParameterParser(['float4' => '']))->getFloat('float4');
+        (new ParameterParser(array('float4' => '')))->getFloat('float4');
     }
 
     public function testGetFloatWithTextString()
     {
         $this->setExpectedException(Exception::class, "Floating-point number expected for parameter 'float5'");
-        (new ParameterParser(['float5' => 'a']))->getFloat('float5');
+        (new ParameterParser(array('float5' => 'a')))->getFloat('float5');
     }
 
 
     public function testGetFloatWithInvalidNumber()
     {
         $this->setExpectedException(Exception::class, "Floating-point number expected for parameter 'float6'");
-        (new ParameterParser(['float6' => '-55.']))->getFloat('float6');
+        (new ParameterParser(array('float6' => '-55.')))->getFloat('float6');
     }
 
 
     public function testGetString()
     {
-        $oParams = new ParameterParser([
+        $oParams = new ParameterParser(array(
                                         'str1' => 'abc',
                                         'str2' => '',
                                         'str3' => '0'
-                                       ]);
+                                       ));
 
         $this->assertSame(false, $oParams->getString('non-exists'));
         $this->assertSame('default', $oParams->getString('non-exists', 'default'));
@@ -121,41 +121,41 @@ class ParameterParserTest extends \PHPUnit_Framework_TestCase
 
     public function testGetSet()
     {
-        $oParams = new ParameterParser([
+        $oParams = new ParameterParser(array(
                                         'val1' => 'foo',
                                         'val2' => '',
                                         'val3' => 0
-                                       ]);
+                                       ));
 
-        $this->assertSame(false, $oParams->getSet('non-exists', ['foo', 'bar']));
-        $this->assertSame('default', $oParams->getSet('non-exists', ['foo', 'bar'], 'default'));
-        $this->assertSame('foo', $oParams->getSet('val1', ['foo', 'bar']));
+        $this->assertSame(false, $oParams->getSet('non-exists', array('foo', 'bar')));
+        $this->assertSame('default', $oParams->getSet('non-exists', array('foo', 'bar'), 'default'));
+        $this->assertSame('foo', $oParams->getSet('val1', array('foo', 'bar')));
 
-        $this->assertSame(false, $oParams->getSet('val2', ['foo', 'bar']));
-        $this->assertSame(0, $oParams->getSet('val3', ['foo', 'bar']));
+        $this->assertSame(false, $oParams->getSet('val2', array('foo', 'bar')));
+        $this->assertSame(0, $oParams->getSet('val3', array('foo', 'bar')));
     }
 
 
     public function testGetSetWithValueNotInSet()
     {
         $this->setExpectedException(Exception::class, "Parameter 'val4' must be one of: foo, bar");
-        (new ParameterParser(['val4' => 'faz']))->getSet('val4', ['foo', 'bar']);
+        (new ParameterParser(array('val4' => 'faz')))->getSet('val4', array('foo', 'bar'));
     }
 
 
     public function testGetStringList()
     {
-        $oParams = new ParameterParser([
+        $oParams = new ParameterParser(array(
                                         'list1' => ',a,b,c,,c,d',
                                         'list2' => 'a',
                                         'list3' => '',
                                         'list4' => '0'
-                                       ]);
+                                       ));
 
         $this->assertSame(false, $oParams->getStringList('non-exists'));
-        $this->assertSame(['a', 'b'], $oParams->getStringList('non-exists', ['a', 'b']));
-        $this->assertSame(['a', 'b', 'c', 'c', 'd'], $oParams->getStringList('list1'));
-        $this->assertSame(['a'], $oParams->getStringList('list2'));
+        $this->assertSame(array('a', 'b'), $oParams->getStringList('non-exists', array('a', 'b')));
+        $this->assertSame(array('a', 'b', 'c', 'c', 'd'), $oParams->getStringList('list1'));
+        $this->assertSame(array('a'), $oParams->getStringList('list2'));
         $this->assertSame(false, $oParams->getStringList('list3'));
         $this->assertSame(false, $oParams->getStringList('list4'));
     }
@@ -163,8 +163,8 @@ class ParameterParserTest extends \PHPUnit_Framework_TestCase
 
     public function testGetPreferredLanguages()
     {
-        $oParams = new ParameterParser(['accept-language' => '']);
-        $this->assertSame([
+        $oParams = new ParameterParser(array('accept-language' => ''));
+        $this->assertSame(array(
                            'short_name:default' => 'short_name:default',
                            'name:default' => 'name:default',
                            'short_name' => 'short_name',
@@ -174,10 +174,10 @@ class ParameterParserTest extends \PHPUnit_Framework_TestCase
                            'official_name' => 'official_name',
                            'ref' => 'ref',
                            'type' => 'type'
-                          ], $oParams->getPreferredLanguages('default'));
+                          ), $oParams->getPreferredLanguages('default'));
 
-        $oParams = new ParameterParser(['accept-language' => 'de,en']);
-        $this->assertSame([
+        $oParams = new ParameterParser(array('accept-language' => 'de,en'));
+        $this->assertSame(array(
                            'short_name:de' => 'short_name:de',
                            'name:de' => 'name:de',
                            'short_name:en' => 'short_name:en',
@@ -190,10 +190,10 @@ class ParameterParserTest extends \PHPUnit_Framework_TestCase
                            'official_name' => 'official_name',
                            'ref' => 'ref',
                            'type' => 'type'
-                          ], $oParams->getPreferredLanguages('default'));
+                          ), $oParams->getPreferredLanguages('default'));
 
-        $oParams = new ParameterParser(['accept-language' => 'fr-ca,fr;q=0.8,en-ca;q=0.5,en;q=0.3']);
-        $this->assertSame([
+        $oParams = new ParameterParser(array('accept-language' => 'fr-ca,fr;q=0.8,en-ca;q=0.5,en;q=0.3'));
+        $this->assertSame(array(
                            'short_name:fr-ca' => 'short_name:fr-ca',
                            'name:fr-ca' => 'name:fr-ca',
                            'short_name:fr' => 'short_name:fr',
@@ -212,6 +212,6 @@ class ParameterParserTest extends \PHPUnit_Framework_TestCase
                            'official_name' => 'official_name',
                            'ref' => 'ref',
                            'type' => 'type',
-                          ], $oParams->getPreferredLanguages('default'));
+                          ), $oParams->getPreferredLanguages('default'));
     }
 }
index 05681ae36539d6bcf47ce6dc3ff987fa3b9683a0..ef9f03c4bd2b648b0c587f92fa1ea186f674daf7 100755 (executable)
@@ -20,7 +20,7 @@ sudo apt-get install -y -qq libboost-dev libboost-system-dev \
 
 sudo apt-get install -y -qq python3-dev python3-pip python3-psycopg2 php5-cgi
 
-pip3 install --quiet behave nose pytidylib psycopg2
+pip3 install --quiet behave nose pytidylib psycopg2-binary
 
 # Travis uses phpenv to support multiple PHP versions. We need to make sure
 # these packages get installed to the phpenv-set PHP (below /home/travis/.phpenv/),
index b9cc88f767ccd19df7a90b00e581d931ab7b8231..71c93715f9e47621304bbcbdc3f88f542ff70e9e 100755 (executable)
@@ -63,7 +63,7 @@ $sQuery = join(',', $aCleanedQueryParts);
 // we initialize these to avoid warnings in our logfile
 $sViewBox = '';
 $bShowPolygons = '';
-$aExcludePlaceIDs = [];
+$aExcludePlaceIDs = array();
 $sMoreURL = '';
 
 include(CONST_BasePath.'/lib/template/search-'.$sOutputFormat.'.php');
index 822081ef7d4caff8973550e909400db78865d599..0251c8c8206d122f24ca0867f1135f2efca61ee8 100755 (executable)
@@ -62,7 +62,7 @@ if (isset($aPlace)) {
         $aPlace = array_merge($aPlace, $aOutlineResult);
     }
 } else {
-    $aPlace = [];
+    $aPlace = array();
 }
 
 logEnd($oDB, $hLog, sizeof($aPlace)?1:0);