def from_dict(cls, data, strict_lon_validation=False): """ data is a GeoJSON standard data structure, including that the coordinates are in GeoJSON order (lon, lat) instead of SimpleGeo order (lat, lon) """ assert isinstance(data, dict), (type(data), repr(data)) coordinates = deep_swap(data['geometry']['coordinates']) try: deep_validate_lat_lon(coordinates, strict_lon_validation=strict_lon_validation) except TypeError, le: raise TypeError("The 'coordinates' value is required to be a 2-element sequence of lon, lat for a point (or a more complicated set of coordinates for polygons or multipolygons), but it was %s :: %r. The error that was raised from validating this was: %s" % (type(coordinates), coordinates, le))
def __init__(self, coordinates, geomtype='Point', simplegeohandle=None, properties=None, strict_lon_validation=False): """ The simplegeohandle and the record_id are both optional -- you can have one or the other or both or neither. A simplegeohandle is globally unique and is assigned by the Places service. It is returned from the Places service in the response to a request to add a place to the Places database (the add_feature method). The simplegeohandle is passed in as an argument to the constructor, named "simplegeohandle", and is stored in the "id" attribute of the Feature instance. A record_id is scoped to your particular user account and is chosen by you. The only use for the record_id is in case you call add_feature and you have already previously added that feature to the database -- if there is already a feature from your user account with the same record_id then the Places service will return that feature to you, along with that feature's simplegeohandle, instead of making a second, duplicate feature. A record_id is passed in as a value in the properties dict named "record_id". geomtype is a GeoJSON geometry type such as "Point", "Polygon", or "Multipolygon". coordinates is a GeoJSON coordinates *except* that each lat/lon pair is written in order lat, lon instead of the GeoJSON order of lon, at. When a Feature is being submitted to the SimpleGeo Places database, if there is a key 'private' in the properties dict which is set to True, then the Feature is intended to be visible only to your user account. If there is no 'private' key or if there is a 'private' key which is set to False, then the Feature is intended to be merged into the publicly visible Places Database. Note that even if it is intended to be merged into the public Places Database the actual process of merging it into the public shared database may take some time, and the newly added Feature will be visible to your account right away even if it isn't (yet) visible to the public. For the meaning of strict_lon_validation, please see the function is_valid_lon(). """ try: deep_validate_lat_lon(coordinates, strict_lon_validation=strict_lon_validation) except TypeError, le: raise TypeError("The first argument, 'coordinates' is required to be a 2-element sequence of lon, lat for a point (or a more complicated set of coordinates for polygons or multipolygons), but it was %s :: %r. The error that was raised from validating this was: %s" % (type(coordinates), coordinates, le))