Skip to content

Commit

Permalink
Merge pull request #44 from GIScience/development
Browse files Browse the repository at this point in the history
Trims coordinates to 6 decimals, closes #28
  • Loading branch information
TimMcCauley authored Aug 7, 2018
2 parents 23aabc2 + feadc04 commit 0aa1fdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions openpoiservice/server/api/query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand All @@ -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)

Expand Down Expand Up @@ -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]),
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion openpoiservice/server/categories/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import yaml
import os


class CategoryTools(object):

def __init__(self, categories_file):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0aa1fdb

Please sign in to comment.