def __init__(self, params, bbox, region, proj_srs, cap_file=None): """!Initializes data needed for iteration through tiles. """ self.proj_srs = proj_srs self.meters_per_unit = None # constant defined in WMTS standard (in meters) self.pixel_size = 0.00028 # parse capabilities file try: # checks all elements needed by this class, # invalid elements are removed cap_tree = WMTSCapabilitiesTree(cap_file) except ParseError as error: grass.fatal( _("Unable to parse tile service file.\n%s\n") % str(error)) self.xml_ns = cap_tree.getxmlnshandler() root = cap_tree.getroot() # get layer tile matrix sets with required projection mat_sets = self._getMatSets( root, params['layers'], params['srs']) #[[TileMatrixSet, TileMatrixSetLink], ....] # TODO: what if more tile matrix sets have required srs (returned more than 1)? mat_set = mat_sets[0][0] mat_set_link = mat_sets[0][1] params['tile_matrix_set'] = mat_set.find( self.xml_ns.NsOws('Identifier')).text # find tile matrix with resolution closest and smaller to wanted resolution tile_mat = self._findTileMats( mat_set.findall(self.xml_ns.NsWmts('TileMatrix')), region, bbox) # get extend of data available on server expressed in max/min rows and cols of tile matrix mat_num_bbox = self._getMatSize(tile_mat, mat_set_link) # initialize data needed for iteration through tiles self._computeRequestData(tile_mat, params, bbox, mat_num_bbox)
def __init__(self, cap_file): """Create common interface for web_services.widgets to WMTS capabilities data """ # checks all elements needed for creation of GetTile requests # by r.in.wms/d.wms modules, invalid elements are removed WMTSCapabilitiesTree.__init__(self, cap_file) contents = self._find(self.getroot(), 'Contents', self.xml_ns.NsWmts) layers = self._findall(contents, 'Layer', self.xml_ns.NsWmts) self.layers_by_id = {} id = 0 root_layer = WMTSLayer(None, id, self) self.layers_by_id[id] = root_layer for layer_node in layers: id += 1 self.layers_by_id[id] = WMTSLayer(layer_node, id, self) root_layer.child_layers.append(self.layers_by_id[id])
def __init__(self, cap_file): """Create common interface for web_services.widgets to WMTS capabilities data """ # checks all elements needed for creation of GetTile requests # by r.in.wms/d.wms modules, invalid elements are removed WMTSCapabilitiesTree.__init__(self, cap_file) contents = self._find(self.getroot(), "Contents", self.xml_ns.NsWmts) layers = self._findall(contents, "Layer", self.xml_ns.NsWmts) self.layers_by_id = {} id = 0 root_layer = WMTSLayer(None, id, self) self.layers_by_id[id] = root_layer for layer_node in layers: id += 1 self.layers_by_id[id] = WMTSLayer(layer_node, id, self) root_layer.child_layers.append(self.layers_by_id[id])
def __init__(self, params, bbox, region, proj_srs, cap_file=None): """!Initializes data needed for iteration through tiles. """ self.proj_srs = proj_srs self.meters_per_unit = None # constant defined in WMTS standard (in meters) self.pixel_size = 0.00028 # parse capabilities file try: # checks all elements needed by this class, # invalid elements are removed cap_tree = WMTSCapabilitiesTree(cap_file) except ParseError as error: grass.fatal(_("Unable to parse tile service file.\n%s\n") % str(error)) self.xml_ns = cap_tree.getxmlnshandler() root = cap_tree.getroot() # get layer tile matrix sets with required projection # [[TileMatrixSet, TileMatrixSetLink], ....] mat_sets = self._getMatSets(root, params['layers'], params['srs']) # TODO: what if more tile matrix sets have required srs (returned more than 1)? mat_set = mat_sets[0][0] mat_set_link = mat_sets[0][1] params['tile_matrix_set'] = mat_set.find(self.xml_ns.NsOws('Identifier')).text # find tile matrix with resolution closest and smaller to wanted resolution tile_mat = self._findTileMats(mat_set.findall( self.xml_ns.NsWmts('TileMatrix')), region, bbox) # get extend of data available on server expressed in max/min rows and cols of tile matrix mat_num_bbox = self._getMatSize(tile_mat, mat_set_link) # initialize data needed for iteration through tiles self._computeRequestData(tile_mat, params, bbox, mat_num_bbox, self._getMatSetSrs(mat_set))