Ejemplo n.º 1
0
    def _computeRequestData(self, tile_mat, params, bbox, mat_num_bbox,
                            mat_set_srs):
        """!Initialize data needed for iteration through tiles."""
        scale_den = float(
            tile_mat.find(self.xml_ns.NsWmts("ScaleDenominator")).text)

        pixel_span = scale_den * self.pixel_size / self._getMetersPerUnit()

        tl_str = tile_mat.find(
            self.xml_ns.NsWmts("TopLeftCorner")).text.split(" ")

        tl_corner = {}
        tl_corner["minx"] = float(tl_str[0])
        tl_corner["maxy"] = float(tl_str[1])

        # TODO do it more generally WMS cap parser may use it in future(not needed now)???
        s = Srs(
            mat_set_srs
        )  # NOTE not used params['srs'], it is just number, encoding needed
        # TODO needs to be tested, tried only on
        # http://www.landesvermessung.sachsen.de/geoserver/gwc/service/wmts?:
        if s.getcode() == "EPSG:4326" and s.encoding in ("uri", "urn"):
            grass.warning("switch")
            (tl_corner["minx"], tl_corner["maxy"]) = (
                tl_corner["maxy"],
                tl_corner["minx"],
            )
        else:
            grass.warning("no switch")

        tile_span = {}
        self.tile_size = {}

        self.tile_size["x"] = int(
            tile_mat.find(self.xml_ns.NsWmts("TileWidth")).text)
        tile_span["x"] = pixel_span * self.tile_size["x"]

        self.tile_size["y"] = int(
            tile_mat.find(self.xml_ns.NsWmts("TileHeight")).text)
        tile_span["y"] = pixel_span * self.tile_size["y"]

        self.url = params["url"] + (
            "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&"
            "LAYER=%s&STYLE=%s&FORMAT=%s&TILEMATRIXSET=%s&TILEMATRIX=%s" % (
                params["layers"],
                params["styles"],
                params["format"],
                params["tile_matrix_set"],
                tile_mat.find(self.xml_ns.NsOws("Identifier")).text,
            ))

        BaseRequestMgr._computeRequestData(self, bbox, tl_corner, tile_span,
                                           self.tile_size, mat_num_bbox)
Ejemplo n.º 2
0
    def _computeRequestData(self, tile_mat, params, bbox, mat_num_bbox, mat_set_srs):
        """!Initialize data needed for iteration through tiles.
        """
        scale_den = float(tile_mat.find(self.xml_ns.NsWmts('ScaleDenominator')).text)

        pixel_span = scale_den * self.pixel_size / self._getMetersPerUnit()

        tl_str = tile_mat.find(self.xml_ns.NsWmts('TopLeftCorner')).text.split(' ')

        tl_corner = {}
        tl_corner['minx'] = float(tl_str[0])
        tl_corner['maxy'] = float(tl_str[1])

        # TODO do it more generally WMS cap parser may use it in future(not needed now)???
        s = Srs(mat_set_srs)  # NOTE not used params['srs'], it is just number, encoding needed
        # TODO needs to be tested, tried only on
        # http://www.landesvermessung.sachsen.de/geoserver/gwc/service/wmts?:
        if s.getcode() == 'EPSG:4326' and s.encoding in ('uri', 'urn'):
            grass.warning('switch')
            (tl_corner['minx'], tl_corner['maxy']) = (tl_corner['maxy'], tl_corner['minx'])
        else:
            grass.warning('no switch')

        tile_span = {}
        self.tile_size = {}

        self.tile_size['x'] = int(tile_mat.find(self.xml_ns.NsWmts('TileWidth')).text)
        tile_span['x'] = pixel_span * self.tile_size['x']

        self.tile_size['y'] = int(tile_mat.find(self.xml_ns.NsWmts('TileHeight')).text)
        tile_span['y'] = pixel_span * self.tile_size['y']

        self.url = params['url'] + ("SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&"
                                    "LAYER=%s&STYLE=%s&FORMAT=%s&TILEMATRIXSET=%s&TILEMATRIX=%s" %
                                    (params['layers'], params['styles'], params['format'],
                                     params['tile_matrix_set'], tile_mat.find(self.xml_ns.NsOws('Identifier')).text))

        BaseRequestMgr._computeRequestData(
            self, bbox, tl_corner, tile_span, self.tile_size, mat_num_bbox)
Ejemplo n.º 3
0
    def _computeRequestData(self, tile_mat, params, bbox, mat_num_bbox, mat_set_srs):
        """!Initialize data needed for iteration through tiles.
        """  
        scale_den = float(tile_mat.find(self.xml_ns.NsWmts('ScaleDenominator')).text)

        pixel_span = scale_den * self.pixel_size / self._getMetersPerUnit()

        tl_str = tile_mat.find(self.xml_ns.NsWmts('TopLeftCorner')).text.split(' ')

        tl_corner = {}
        tl_corner['minx'] = float(tl_str[0])
        tl_corner['maxy'] = float(tl_str[1])

        #TODO do it more generally WMS cap parser may use it in future(not needed now)???
        s = Srs(mat_set_srs) #NOTE not used params['srs'], it is just number, encoding needed
        # TODO needs to be tested, tried only on http://www.landesvermessung.sachsen.de/geoserver/gwc/service/wmts?:
        if s.getcode() == 'EPSG:4326' and s.encoding in ('uri', 'urn'):
            grass.warning('switch')
            (tl_corner['minx'], tl_corner['maxy']) = (tl_corner['maxy'], tl_corner['minx'])
        else:
            grass.warning('no switch')

        tile_span = {}
        self.tile_size = {}

        self.tile_size['x'] = int(tile_mat.find(self.xml_ns.NsWmts('TileWidth')).text)
        tile_span['x'] = pixel_span * self.tile_size['x']
        
        self.tile_size['y'] = int(tile_mat.find(self.xml_ns.NsWmts('TileHeight')).text)
        tile_span['y'] = pixel_span * self.tile_size['y']

        self.url = params['url'] + ("SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&" \
                                    "LAYER=%s&STYLE=%s&FORMAT=%s&TILEMATRIXSET=%s&TILEMATRIX=%s" % \
                                   (params['layers'], params['styles'], params['format'],
                                    params['tile_matrix_set'], tile_mat.find(self.xml_ns.NsOws('Identifier')).text ))

        BaseRequestMgr._computeRequestData(self, bbox, tl_corner, tile_span, self.tile_size, mat_num_bbox)