def _get_self_bounds(self): """ Computes the bounds of the object itself (not including it's children) in the form [[lat_min, lon_min], [lat_max, lon_max]]. """ if not self.embed: raise ValueError('Cannot compute bounds of non-embedded GeoJSON.') data = json.loads(self.data) if 'features' not in data.keys(): # Catch case when GeoJSON is just a single Feature or a geometry. if not (isinstance(data, dict) and 'geometry' in data.keys()): # Catch case when GeoJSON is just a geometry. data = {'type': 'Feature', 'geometry': data} data = {'type': 'FeatureCollection', 'features': [data]} bounds = [[None, None], [None, None]] for feature in data['features']: for point in iter_points( feature.get('geometry', {}).get('coordinates', {})): # noqa bounds = [ [ none_min(bounds[0][0], point[1]), none_min(bounds[0][1], point[0]), ], [ none_max(bounds[1][0], point[1]), none_max(bounds[1][1], point[0]), ], ] return bounds
def _get_self_bounds(self): """Computes the bounds of the object itself (not including it's children) in the form [[lat_min, lon_min], [lat_max, lon_max]] """ if not self.embed: raise ValueError('Cannot compute bounds of non-embedded GeoJSON.') data = json.loads(self.data) if 'features' not in data.keys(): # Catch case when GeoJSON is just a single Feature or a geometry. if not (isinstance(data, dict) and 'geometry' in data.keys()): # Catch case when GeoJSON is just a geometry. data = {'type' : 'Feature', 'geometry' : data} data = {'type' : 'FeatureCollection', 'features' : [data]} bounds = [[None,None],[None,None]] for feature in data['features']: for point in iter_points(feature.get('geometry',{}).get('coordinates',{})): bounds = [ [ none_min(bounds[0][0], point[1]), none_min(bounds[0][1], point[0]), ], [ none_max(bounds[1][0], point[1]), none_max(bounds[1][1], point[0]), ], ] return bounds