From 1cfd97dd2f9051d42e9b0ed0e504ae6e24decdd7 Mon Sep 17 00:00:00 2001 From: Jorge Samuel Mendes de Jesus Date: Sun, 29 Apr 2018 13:20:01 +0200 Subject: [PATCH] Remove GeoJSON dependency from sqlite module (#36) --- pygeoapi/provider/sqlite.py | 21 ++++++++++++++------- requirements.txt | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/pygeoapi/provider/sqlite.py b/pygeoapi/provider/sqlite.py index f49d7e3..4ac7596 100644 --- a/pygeoapi/provider/sqlite.py +++ b/pygeoapi/provider/sqlite.py @@ -30,7 +30,7 @@ import sqlite3 import logging import os -import geojson +import json from pygeoapi.provider.base import BaseProvider, ProviderConnectionError from pygeoapi.provider import InvalidProviderError @@ -73,13 +73,18 @@ class SQLiteProvider(BaseProvider): feature_list = list() for row_data in self.dataDB: row_data = dict(row_data) # sqlite3.Row is doesnt support pop - geom = geojson.loads(row_data['AsGeoJSON(geometry)']) - del row_data['AsGeoJSON(geometry)'] - feature = geojson.Feature(geometry=geom, properties=row_data) - feature['ID'] = feature['properties'][self.id_field] + feature = {} + feature["geometry"] = json.loads( + row_data.pop('AsGeoJSON(geometry)') + ) + feature['properties'] = row_data + feature['id'] = feature['properties'].pop(self.id_field) feature_list.append(feature) - feature_collection = geojson.FeatureCollection(feature_list) + feature_collection = { + 'type': 'FeatureCollection', + 'features': feature_list + } return feature_collection @@ -89,8 +94,10 @@ class SQLiteProvider(BaseProvider): :returns: GeoJSON FeaturesCollection """ - feature_collection = geojson.FeatureCollection([]) + feature_collection = {"features": [], + "type": "FeatureCollection"} feature_collection['numberMatched'] = str(hits) + return feature_collection def __load(self): diff --git a/requirements.txt b/requirements.txt index 6078f0b..b432fbc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ Flask Shapely Flask_Cors PyYAML -geojson +json