]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/bdd/steps/geometry_factory.py
move country names into separate include files
[nominatim.git] / test / bdd / steps / geometry_factory.py
index 7eedfc37a41ffe3c57db5985767ce67686abdbbd..d62ad9c5b07d897d0e0e9eb84e7d4884c8cfe82d 100644 (file)
@@ -1,3 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2022 by the Nominatim developer community.
+# For a full list of authors see the git log.
 from pathlib import Path
 import os
 
@@ -9,7 +15,7 @@ class GeometryFactory:
         defpath = Path(__file__) / '..' / '..' / '..' / 'scenes' / 'data'
         self.scene_path = os.environ.get('SCENE_PATH', defpath.resolve())
         self.scene_cache = {}
-        self.clear_grid()
+        self.grid = {}
 
     def parse_geometry(self, geom, scene):
         """ Create a WKT SQL term for the given geometry.
@@ -103,11 +109,20 @@ class GeometryFactory:
 
         return scene
 
-    def clear_grid(self):
+    def set_grid(self, lines, grid_step):
+        """ Replace the grid with one from the given lines.
+        """
         self.grid = {}
-
-    def add_grid_node(self, nodeid, x, y):
-        self.grid[nodeid] = (x, y)
+        y = 0
+        for line in lines:
+            x = 0
+            for pt_id in line:
+                if pt_id.isdigit():
+                    self.grid[int(pt_id)] = (x, y)
+                x += grid_step
+            y += grid_step
 
     def grid_node(self, nodeid):
+        """ Get the coordinates for the given grid node.
+        """
         return self.grid.get(nodeid)