diff --git a/openpoiservice/server/api/query_builder.py b/openpoiservice/server/api/query_builder.py index 280b2ef..75073bb 100644 --- a/openpoiservice/server/api/query_builder.py +++ b/openpoiservice/server/api/query_builder.py @@ -6,7 +6,7 @@ from geoalchemy2.types import Geography, Geometry from geoalchemy2.elements import WKBElement, WKTElement from shapely import wkb -from shapely.geometry import MultiPoint +from shapely.geometry import MultiPoint, Point from openpoiservice.server.db_import.models import Pois, Tags, Categories from sqlalchemy.sql.expression import type_coerce from sqlalchemy import func, cast, Integer, ARRAY @@ -92,7 +92,7 @@ def request_pois(self): elif params['sortby'] == 'category': sortby_group.append(bbox_query.c.category) - start = timer() + # start = timer() keys_agg = func.array_agg(Tags.key).label('keys') values_agg = func.array_agg(Tags.value).label('values') @@ -117,10 +117,10 @@ def request_pois(self): .group_by(bbox_query.c.geom) \ # .all() - end = timer() - print(end - start) + # end = timer() + # print(end - start) - print(str(pois_query)) + #print(str(pois_query)) # for dude in pois_query: # print(dude) @@ -242,7 +242,11 @@ def generate_geojson_features(cls, query, limit): for q_idx, q in enumerate(query): geometry = wkb.loads(str(q[3]), hex=True) - lat_lngs.append((geometry.x, geometry.y)) + x = float(format(geometry.x, ".6f")) + y = float(format(geometry.y, ".6f")) + trimmed_point = Point(x, y) + + lat_lngs.append((trimmed_point.x, trimmed_point.y)) properties = dict( osm_id=int(q[0]), @@ -267,7 +271,7 @@ def generate_geojson_features(cls, query, limit): properties["osm_tags"] = key_values - geojson_feature = geojson.Feature(geometry=geometry, + geojson_feature = geojson.Feature(geometry=trimmed_point, properties=properties) geojson_features.append(geojson_feature) diff --git a/openpoiservice/server/categories/categories.py b/openpoiservice/server/categories/categories.py index a5a027d..83487f2 100644 --- a/openpoiservice/server/categories/categories.py +++ b/openpoiservice/server/categories/categories.py @@ -3,7 +3,6 @@ import yaml import os - class CategoryTools(object): def __init__(self, categories_file): @@ -55,6 +54,7 @@ def generate_category_indices(self): for tag_name, pois in group_children.items(): if tag_name in self.category_index: + self.category_index[tag_name].update(pois) else: self.category_index[tag_name] = pois