本文整理汇总了Python中django.contrib.gis.geos.GeometryCollection方法的典型用法代码示例。如果您正苦于以下问题:Python geos.GeometryCollection方法的具体用法?Python geos.GeometryCollection怎么用?Python geos.GeometryCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.gis.geos
的用法示例。
在下文中一共展示了geos.GeometryCollection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transform_value_for_tile
# 需要导入模块: from django.contrib.gis import geos [as 别名]
# 或者: from django.contrib.gis.geos import GeometryCollection [as 别名]
def transform_value_for_tile(self, value, **kwargs):
if "format" in kwargs and kwargs["format"] == "esrijson":
arches_geojson = GeoUtils().arcgisjson_to_geojson(value)
else:
arches_geojson = {}
arches_geojson["type"] = "FeatureCollection"
arches_geojson["features"] = []
geometry = GEOSGeometry(value, srid=4326)
if geometry.geom_type == "GeometryCollection":
for geom in geometry:
arches_json_geometry = {}
arches_json_geometry["geometry"] = JSONDeserializer().deserialize(GEOSGeometry(geom, srid=4326).json)
arches_json_geometry["type"] = "Feature"
arches_json_geometry["id"] = str(uuid.uuid4())
arches_json_geometry["properties"] = {}
arches_geojson["features"].append(arches_json_geometry)
else:
arches_json_geometry = {}
arches_json_geometry["geometry"] = JSONDeserializer().deserialize(geometry.json)
arches_json_geometry["type"] = "Feature"
arches_json_geometry["id"] = str(uuid.uuid4())
arches_json_geometry["properties"] = {}
arches_geojson["features"].append(arches_json_geometry)
return arches_geojson
示例2: _set_geom
# 需要导入模块: from django.contrib.gis import geos [as 别名]
# 或者: from django.contrib.gis.geos import GeometryCollection [as 别名]
def _set_geom(self):
xform = self.xform
data_dictionary = xform.data_dictionary()
geo_xpaths = data_dictionary.geopoint_xpaths()
doc = self.get_dict()
points = []
if len(geo_xpaths):
for xpath in geo_xpaths:
geometry = [float(s) for s in doc.get(xpath, u'').split()]
if len(geometry):
lat, lng = geometry[0:2]
points.append(Point(lng, lat))
if not xform.instances_with_geopoints and len(points):
xform.instances_with_geopoints = True
xform.save()
self.geom = GeometryCollection(points)
示例3: get_geometry_fieldnames
# 需要导入模块: from django.contrib.gis import geos [as 别名]
# 或者: from django.contrib.gis.geos import GeometryCollection [as 别名]
def get_geometry_fieldnames(self, instance):
"""
Finds GeometryCollection field in a flattened resource intance to use as the geometry of each shapefile record.
"""
geometry_fields = []
for k, v in instance.items():
if isinstance(v, GeometryCollection):
geometry_fields.append(k)
return geometry_fields
示例4: create_geom_collection_from_geojson
# 需要导入模块: from django.contrib.gis import geos [as 别名]
# 或者: from django.contrib.gis.geos import GeometryCollection [as 别名]
def create_geom_collection_from_geojson(self, geojson):
geoms = []
for feature in geojson["features"]:
geoms.append(GEOSGeometry(JSONSerializer().serialize(feature["geometry"])))
return GeometryCollection(geoms)
示例5: transform_export_values
# 需要导入模块: from django.contrib.gis import geos [as 别名]
# 或者: from django.contrib.gis.geos import GeometryCollection [as 别名]
def transform_export_values(self, value, *args, **kwargs):
wkt_geoms = []
for feature in value["features"]:
wkt_geoms.append(GEOSGeometry(json.dumps(feature["geometry"])))
return GeometryCollection(wkt_geoms)
示例6: geometry
# 需要导入模块: from django.contrib.gis import geos [as 别名]
# 或者: from django.contrib.gis.geos import GeometryCollection [as 别名]
def geometry(feat):
"""Constructs a GEOSGeometryCollection from a GeoJSON dict.
"""
return GeometryCollection(_geometry(feat), srid=4326)
示例7: __init__
# 需要导入模块: from django.contrib.gis import geos [as 别名]
# 或者: from django.contrib.gis.geos import GeometryCollection [as 别名]
def __init__(self, geom):
"""
Oracle requires that polygon rings are in proper orientation. This
affects spatial operations and an invalid orientation may cause
failures. Correct orientations are:
* Outer ring - counter clockwise
* Inner ring(s) - clockwise
"""
if isinstance(geom, Polygon):
self._fix_polygon(geom)
elif isinstance(geom, GeometryCollection):
self._fix_geometry_collection(geom)
self.wkt = geom.wkt
self.srid = geom.srid