/usr/lib/python2.7/dist-packages/geojson/feature.py is in python-geojson 2.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | """
SimpleWebFeature is a working example of a class that satisfies the Python geo
interface.
"""
from geojson.base import GeoJSON
class Feature(GeoJSON):
"""
Represents a WGS84 GIS feature.
"""
def __init__(self, id=None, geometry=None, properties=None, **extra):
"""
Initialises a Feature object with the given parameters.
:param id: Feature identifier, such as a sequential number.
:type id: str, int
:param geometry: Geometry corresponding to the feature.
:param properties: Dict containing properties of the feature.
:type properties: dict
:return: Feature object
:rtype: Feature
"""
super(Feature, self).__init__(**extra)
if id is not None:
self["id"] = id
self["geometry"] = (self.to_instance(geometry, strict=True)
if geometry else None)
self["properties"] = properties or {}
def errors(self):
geo = self.get('geometry')
return geo.errors() if geo else None
class FeatureCollection(GeoJSON):
"""
Represents a FeatureCollection, a set of multiple Feature objects.
"""
def __init__(self, features, **extra):
"""
Initialises a FeatureCollection object from the
:param features: List of features to constitute the FeatureCollection.
:type features: list
:return: FeatureCollection object
:rtype: FeatureCollection
"""
super(FeatureCollection, self).__init__(**extra)
self["features"] = features
def errors(self):
return self.check_list_errors(lambda x: x.errors(), self.features)
def __getitem__(self, key):
try:
return self.get("features", ())[key]
except (KeyError, TypeError, IndexError):
return super(GeoJSON, self).__getitem__(key)
|