Python GeoJSONConstructor Example

说明

python geojsonconstructor示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: Python

命名空间/包名称: pgsql2gist

示例#1
文件: test_geojson.py项目: mattmakesmaps/pgsql2gist

 def test_outofboundserror(self):
     """
     Check that given a properly formatted dict, that a string representing a
     GeoJSON Feature Collection is returned.
     """
     constructor = GeoJSONConstructor(self.records, 'geometry')
     feature_collection = constructor.encode()
     expected_value = '{"type": "FeatureCollection", "features": [{"geometry": {"type": "Point", "coordinates": [-122.27, 47.69]}, "type": "Feature", "properties": {"hoods_": 2.0}}, {"geometry": {"type": "Point", "coordinates": [-122.28, 47.64]}, "type": "Feature", "properties": {"hoods_": 3.0}}]}'

示例#2
文件: test_geojson.py项目: mattmakesmaps/pgsql2gist

 def test_encoding(self):
     """
     Check that given a properly formatted dict, that a string representing a
     GeoJSON Feature Collection is returned.
     """
     constructor = GeoJSONConstructor(self.records, 'geometry')
     feature_collection = constructor.encode()
     expected_value = '{"type": "FeatureCollection", "features": [{"geometry": {"type": "MultiPolygon", "coordinates": [[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]], [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]]}, "type": "Feature", "properties": {"hoods_": 2.0}}]}'
     assert feature_collection == expected_value

展开阅读全文