def test_load_bulk(): js1 = open(resource_file(os.path.join('owc_geojson_examples','from-meta-resource.json')), 'r').read() js2 = open(resource_file(os.path.join('owc_geojson_examples','ingest1.owc.geojson')), 'r').read() js3 = open(resource_file(os.path.join('owc_geojson_examples','newzealand-overview.json')), 'r').read() js4 = open(resource_file(os.path.join('owc_geojson_examples','owc1.geojson')), 'r').read() js5 = open(resource_file(os.path.join('owc_geojson_examples','owc2.geojson')), 'r').read() js6 = open(resource_file(os.path.join('owc_geojson_examples','owc3.geojson')), 'r').read() js7 = open(resource_file(os.path.join('owc_geojson_examples','sac-casestudies.json')), 'r').read() feeds = [js1, js2, js3,js4, js5, js6, js7 ] for f in feeds: logger.debug(f) dict_obj = decode_json(f) assert dict_obj is not None # logger.debug(dict_obj) owc = OwcContext.from_dict(dict_obj) assert owc is not None # logger.debug(OwcContext.from_dict(dict_obj).to_json()) jsdata = owc.to_json() assert jsdata is not None assert len(jsdata) > 10 re_owc = OwcContext.from_json(jsdata) assert re_owc is not None through = OwcContext.from_json(f) assert owc.to_dict() == through.to_dict()
def test_load_parse(): jsondata = open( resource_file(os.path.join('owc_geojson_examples', 'owc1.geojson')), 'rb').read().decode('utf-8') # logger.debug(jsondata) my_dict = decode_json(jsondata) logger.debug(str(my_dict)) assert my_dict is not None
def test_decode_single_json(): jsondata1 = open( resource_file(os.path.join('owc_geojson_examples', 'owc1.geojson')), 'r').read() result = decode_json(jsondata1) assert result is not None assert result['features'][0]['properties'][ 'date'] == "2013-11-02T15:24:24.446+12:00"
def test_json_decode(): jsdata = """{ "type": "FeatureCollection", "id": "http://www.opengis.net/owc/1.0/examples/wps_52north/", "features": [ { "id": "http://geoprocessing.demo.52north.org:8080/wps/WebProcessingService/process1/", "geometry": null, "properties": { "categories": [], "date": "2013-11-02T15:24:24.446+12:00" } } ] }""" result = decode_json(jsdata) assert result is not None assert result['features'][0]['properties']['date'] == "2013-11-02T15:24:24.446+12:00"
def test_decode_single_json(): jsondata1 = open(resource_file(os.path.join('owc_geojson_examples', 'owc1.geojson')), 'r').read() result = decode_json(jsondata1) assert result is not None assert result['features'][0]['properties']['date'] == "2013-11-02T15:24:24.446+12:00"
def test_load_parse(): jsondata = open(resource_file(os.path.join('owc_geojson_examples', 'owc1.geojson')), 'rb').read().decode('utf-8') # logger.debug(jsondata) my_dict = decode_json(jsondata) logger.debug(str(my_dict)) assert my_dict is not None
def from_json(cls, jsondata): d = decode_json(jsondata) return cls.from_dict(d)
def from_json(cls, jsondata): d = decode_json(jsondata) # TODO should validate if geojson Type == Feature? return cls.from_dict(d)
def from_json(cls, jsondata): d = decode_json(jsondata) # TODO add spec url conversion from geojson to generic # TODO should validate if geojson Type == FeatureCollection? return cls.from_dict(d)