def features(self, ds, start=0,limit = None, per_req=30): if limit is None: limit = ds.feature_count gen = jsonwrap.map_many(features.Feature).map sofar = 0 while sofar < limit: if (sofar + per_req) >= limit: per_req = limit - sofar u = self.url("dataset_features_url", start=sofar, limit=per_req, id=ds.geoiq_id) fin,res = self.do_req(u, "GET", None, unwrapper=gen) for f in fin: sofar+=1 yield f
def features(self, ds, start=0, limit=None, per_req=30): if limit is None: limit = ds.feature_count gen = jsonwrap.map_many(features.Feature).map sofar = 0 while sofar < limit: if (sofar + per_req) >= limit: per_req = limit - sofar u = self.url("dataset_features_url", start=sofar, limit=per_req, id=ds.geoiq_id) fin, res = self.do_req(u, "GET", None, unwrapper=gen) for f in fin: sofar += 1 yield f
class Map(geoiq.GeoIQObj): writeable = True def add_layer(self, source): if self.layers is None: self.layers = [] if not isinstance(source, LayerSource): source = LayerSource(source, self.geoiq) res = Layer({"source": source}) fin = self.svc.map_add_layer(self, res) self.refresh() for l in self.layers: if (l.source.dataset_id == source.dataset_id): return l raise ValueError("Couldn't find the saved layer?") jsonwrap.props( Map, "title", "basemap", "description", "tags", "extent", "projection", "permissions", # TODO: map to permissions layers={"map": jsonwrap.map_many(Layer)}, contributor={"ro": True})
writeable = True def add_layer(self, source): if self.layers is None: self.layers = [] if not isinstance(source, LayerSource): source = LayerSource(source, self.geoiq) res = Layer({"source":source}) fin = self.svc.map_add_layer(self, res) self.refresh() for l in self.layers: if (l.source.dataset_id == source.dataset_id): return l raise ValueError("Couldn't find the saved layer?") jsonwrap.props(Map, "title", "basemap", "description", "tags", "extent", "projection", "permissions", # TODO: map to permissions layers={"map":jsonwrap.map_many(Layer)}, contributor={"ro":True})
loader = self.geoiq.maps.get_by_id elif self.is_analysis(): loader = self.geoiq.analysis.get_by_id if (loader is None): raise NotImplementedError("No implementation for: " + tp + "yet.") return loader(self.key) jsonwrap.props(SearchPointer, "detail_link", "description", "type", "tags", "author", "title", "id") def search_pointers(ptrs, *args, **kwargs): return [SearchPointer(p, *args, **kwargs) for p in ptrs] class SearchPage(jsonwrap.JsonWrappedObj): pass jsonwrap.props(SearchPage, "totalResults", "itemsPerPage", "next", entries={ "ro": True, "map": jsonwrap.map_many(SearchPointer) })
loader = self.geoiq.analysis.get_by_id if (loader is None): raise NotImplementedError("No implementation for: " + tp + "yet.") return loader(self.key) jsonwrap.props(SearchPointer, "detail_link", "description", "type", "tags", "author", "title", "id") def search_pointers(ptrs, *args, **kwargs): return [SearchPointer(p,*args,**kwargs) for p in ptrs] class SearchPage(jsonwrap.JsonWrappedObj): pass jsonwrap.props(SearchPage, "totalResults", "itemsPerPage", "next", entries={ "ro":True, "map": jsonwrap.map_many(SearchPointer) })