Repository: geoportail-luxembourg/geoportailv3
Issue: getFeatureInfo MyMaps Layers - Select Point get all Points

seems to be a general problem with mymaps layers and multipoint geometries


Changed files:
geoportailv3/views/getfeatureinfo.py

diff --git a/geoportailv3/views/getfeatureinfo.py b/geoportailv3/views/getfeatureinfo.py
index 2c435d1d..981f25d1 100644
--- a/geoportailv3/views/getfeatureinfo.py
+++ b/geoportailv3/views/getfeatureinfo.py
@@ -373,29 +373,38 @@ class Getfeatureinfo(object):
     def get_info_from_mymaps(self, rows, attributes_to_remove):
         features = []
         ids = []
-
         for row in rows:
             category_id = row['category_id']
             map_id = row['map_id']
             cur_id = str(map_id) + "--" + str(category_id)
             if cur_id not in ids:
                 ids.append(cur_id)
-                engine = sqlahelper.get_engine("mymaps")
-                query = "select  ST_AsGeoJSON(ST_Collect (geometry)) as geometry\\
-                        , sum(ST_Length(geometry)) as length FROM\\
-                         public.feature_with_map_with_colors where\\
-                         category_id = %(category_id)d and map_id = '%(map_id)s'"\\
-                        % {'category_id': category_id, 'map_id': map_id}
-                res = engine.execute(query)
-                for feature in res.fetchall():
-                    geometry = geojson_loads(feature['geometry'])
+                geometry = geojson_loads(row['st_asgeojson'])
+                if geometry['type'] == "LineString" or\\
+                   geometry['type'] == "MultiLineString":
+                    engine = sqlahelper.get_engine("mymaps")
+                    query = "select  ST_AsGeoJSON(ST_Collect (geometry)) as geometry\\
+                            , sum(ST_Length(geometry)) as length FROM\\
+                             public.feature_with_map_with_colors where\\
+                             category_id = %(category_id)d and map_id = '%(map_id)s'"\\
+                            % {'category_id': category_id, 'map_id': map_id}
+                    res = engine.execute(query)
+                    for feature in res.fetchall():
+                        geometry = geojson_loads(feature['geometry'])
+                        attributes = dict(row)
+                        attributes['length'] = round(feature['length'] / 1000,
+                                                     2)
+                        self.remove_attributes(attributes,
+                                               attributes_to_remove,
+                                               "geometry")
+                        features.append(
+                            self.to_feature(geometry, attributes, ""))
+                else:
                     attributes = dict(row)
-                    attributes['length'] = round(feature['length'] / 1000, 2)
                     self.remove_attributes(attributes,
                                            attributes_to_remove,
                                            "geometry")
                     features.append(self.to_feature(geometry, attributes, ""))
-
         return features
 
     def _get_external_data(self, url, bbox=None, featureid=None, cfg=None,