Exemple #1
0
    def __get_epsg_xy_axes_labels(self):
        """
        Return a tuple of axis labels for X and Y axes
        """
        axes_labels = CRSUtil.get_axis_labels_from_single_crs(self.epsg_xy_crs)
        axis_type1 = CRSAxis.get_axis_type_by_name(axes_labels[0])

        # XY order (e.g: EPSG:3857)
        if axis_type1 == CRSAxis.AXIS_TYPE_X:
            return axes_labels[0], axes_labels[1]
        else:
            # YX order (e.g: EPSG:4326) needs to swap order
            return axes_labels[1], axes_labels[0]
Exemple #2
0
    def get_running_crs_resolver(self, crs_resolvers, embedded_petascope_port):
        """
        From a list of SECORE configured in petascope.properties, find the first running SECORE
        to be used for wcst_import
        :param string[] crs_resolvers: list of SECORE URLs
        :return: string (the running SECORE)
        """
        i = 0
        crs_resolvers_tmp = []
        for url_prefix in crs_resolvers:
            url_prefix = url_prefix.strip()

            # NOTE: if secore_urls=internal in petascope.properties, it means
            # wcst_import will use the internal SECORE inside petascope with the sub endpoint at /rasdaman/def
            if url_prefix == INTERNAL_SECORE or url_prefix == DEFAULT_SECORE_URL:
                url_prefix = INTERNAL_SECORE_URL

                crs_resolvers_tmp.append(url_prefix)

                # Also, in case petascope runs at different port than 8080
                if embedded_petascope_port != "8080":
                    url_prefix = "http://localhost:" + embedded_petascope_port + INTERNAL_SECORE_URL_CONTEXT_PATH
                    crs_resolvers_tmp.append(url_prefix)
            else:
                crs_resolvers_tmp.append(url_prefix)

        for url_prefix in crs_resolvers_tmp:
            try:
                url_prefix = url_prefix.strip()

                test_url = url_prefix + "/crs/EPSG/0/4326"
                from util.crs_util import CRSUtil
                Session.RUNNING_SECORE_URL = url_prefix
                CRSUtil.get_axis_labels_from_single_crs(test_url)

                # e.g: http://localhost:8080/def
                return url_prefix
            except Exception as ex:
                log.warn("CRS resolver '" + url_prefix + "' is not working.")
                if i < len(crs_resolvers) - 1:
                    log.warn("Trying with another fallback resolver...")
            i += 1

        # none of resolvers work, then assume there is SECORE embedded in petascope
        internal_secore_url = self.wcs_service.replace(
            "/rasdaman/ows", "/rasdaman/def").strip()
        try:
            test_url = internal_secore_url + "/crs/EPSG/0/4326"
            from util.crs_util import CRSUtil
            Session.RUNNING_SECORE_URL = internal_secore_url
            CRSUtil.get_axis_labels_from_single_crs(test_url)

            log.warn(
                "None of the configured secore_urls in petascope.properties respond to requests. "
                "wcst_import will use the internal CRS resolver at endpoint '"
                + internal_secore_url + "'. "
                "Hint: set secore_urls=internal in petascope.properties to suppress this warning."
            )

            return internal_secore_url
        except Exception as ex:
            raise RuntimeException(
                "No configured CRS resolvers in petascope.properties work. Given: "
                + ",".join(crs_resolvers))