def rect(self): if not self.feature: env = self.data['boundedBy']['Envelope'] d = Parse.pos(env['lowerCorner']) u = Parse.pos(env['upperCorner']) return GeoRect(d[0], u[1], u[0] - d[0], u[1] - d[1]) else: if 'boundedBy' in self.data['properties']: return GeoRect.bounding(self.data['properties']['boundedBy']) else: return GeoRect(*self.data['geometry']['coordinates'], 0, 0)
def bounding(self): if self.mode_init: pm = self.pos_mode if pm == 'bbox': return self.pars['bbox'].copy() elif pm == 'spn': r = GeoRect() r.size = self.pars['spn'] r.center = self.pars['ll'] return r else: return None
def center(self, pos): mode = self.pos_mode if mode == 'bbox': if self.mode_init: self.pars['bbox'].center = pos else: self.pars['bbox'] = GeoRect(*pos, 0, 0) elif mode == 'spn': self.pars['ll'] = list(pos) if not self.mode_init: self.pars['ll'] = [0, 0] self.mode_init = True
def rect(self, rect): pos_mode = self.pos_mode rect = GeoRect(rect) if pos_mode == 'bbox': self.pars['bbox'] = rect elif pos_mode == 'spn': self.pars['ll'] = rect.center self.pars['spn'] = rect.size else: raise AttributeError( '.rect is a linked rectangle and not available if position mode != "bbox"\n' 'You can use read-only .bounding() or change mode') self.mode_init = True
def include_view(self, obj): if hasattr(obj, 'rect'): rect = obj.rect elif len(obj) == 4: rect = GeoRect(obj) elif len(obj) == 2: rect = GeoRect(*obj, 0, 0) else: return rect.inflate_ip(rect.w * .5, rect.h * .5) if self.mode_init: self.rect = self.bounding().union(rect) else: self.rect = rect
def rect(self): bbox = self.data['properties']['ResponseMetaData']['SearchResponse'][ 'boundedBy'] return GeoRect.bounding(bbox)
def rect(self): env = self.data['metaDataProperty']['GeocoderResponseMetaData'][ 'boundedBy']['Envelope'] d = Parse.pos(env['lowerCorner']) u = Parse.pos(env['upperCorner']) return GeoRect(d[0], u[1], u[0] - d[0], u[1] - d[1])