예제 #1
0
    def getSRS(self,srsname,typename):
        """Returns None or Crs object for given name

        @param typename:  feature name 
        @type typename: String
        """
        if type(srsname) == type(""):
            srs = Crs(srsname)
        else:
            srs = srsname

        srss = map(lambda crs: crs.getcodeurn(),
                self.contents[typename].crsOptions)

        for s in srss:
            s = Crs(s)
            if srs.authority == s.authority and\
                    srs.code == s.code:
                if s.version and srs.version:
                    if s.version  == srs.version:
                        idx = srss.index(s.getcodeurn())
                        return self.contents[typename].crsOptions[idx]
                else:
                    idx = srss.index(s.getcodeurn())
                    return self.contents[typename].crsOptions[idx]
        return None
예제 #2
0
    def getSRS(self,srsname,typename):
        """Returns None or Crs object for given name

        @param typename:  feature name 
        @type typename: String
        """
        if type(srsname) == type(""):
            srs = Crs(srsname)
        else:
            srs = srsname

        srss = [crs.getcodeurn() for crs in self.contents[typename].crsOptions]

        for s in srss:
            s = Crs(s)
            if srs.authority == s.authority and\
                    srs.code == s.code:
                if s.version and srs.version:
                    if s.version  == srs.version:
                        idx = srss.index(s.getcodeurn())
                        return self.contents[typename].crsOptions[idx]
                else:
                    idx = srss.index(s.getcodeurn())
                    return self.contents[typename].crsOptions[idx]
        return None
예제 #3
0
    def getBBOXKVP(self, bbox, typename):
        """Formate bounding box for KVP request type (HTTP GET)

        @param bbox: (minx,miny,maxx,maxy[,srs])
        @type bbox: List
        @param typename:  feature name
        @type typename: String
        @returns: String properly formated according to version and
            coordinate reference system
        """
        srs = None

        # srs of the bbox is specified in the bbox as fifth paramter
        if len(bbox) == 5:
            srs = Crs(bbox[4])
        # take default srs
        else:
            srs = self.contents[typename[0]].crsOptions[0]

        # 1.1.0 and 2.0.0 have same encoding
        if self.version in ["1.1.0", "2.0.0"]:

            # format bbox parameter
            if srs.encoding == "urn":
                if srs.axisorder == "yx":
                    return "%s,%s,%s,%s,%s" % (
                        bbox[1],
                        bbox[0],
                        bbox[3],
                        bbox[2],
                        srs.getcodeurn(),
                    )
                else:
                    return "%s,%s,%s,%s,%s" % (
                        bbox[0],
                        bbox[1],
                        bbox[2],
                        bbox[3],
                        srs.getcodeurn(),
                    )
            else:
                return "%s,%s,%s,%s,%s" % (
                    bbox[0],
                    bbox[1],
                    bbox[2],
                    bbox[3],
                    srs.getcode(),
                )
        # 1.0.0
        else:
            return "%s,%s,%s,%s,%s" % (
                bbox[0],
                bbox[1],
                bbox[2],
                bbox[3],
                srs.getcode(),
            )
예제 #4
0
    def getBBOXPost(self, bbox, typename):
        """Format bounding box for Post requests

        @param bbox: (minx,miny,maxx,maxy[,srs])
        @type bbox: List
        @param typename:  feature name
        @type typename: String
        @returns: String properly formated according to version and
            coordinate reference system
        """
        srs = None

        # srs of the bbox is specified in the bbox as fifth paramter
        if len(bbox) == 5:
            srs = Crs(bbox[4])
        # take default srs
        else:
            srs = self.contents[typename[0]].crsOptions[0]

        formatted_bbox = [bbox[0], bbox[1], bbox[2], bbox[3]]
        if self.version in ["1.1.0", "2.0.0"]:
            if srs.axisorder == "yx" and srs.encoding == "urn":
                formatted_bbox = [bbox[1], bbox[0], bbox[3], bbox[2]]

            if self.version == "1.1.0":
                formatted_bbox.append(srs.getcodeurn())
                return formatted_bbox
            if self.version == "2.0.0":
                formatted_bbox.append(srs.getcodeuri1())
                return formatted_bbox
        else:
            formatted_bbox.append(srs.getcode())
            return formatted_bbox
예제 #5
0
파일: wfs110.py 프로젝트: bukun/CSWClient
    def getSRS(self, srsname, typename):
        """Returns None or Crs object for given name
        """
        if type(srsname) == type(""):
            srs = Crs(srsname)
        else:
            srs = srsname

        srss = map(lambda crs: crs.getcodeurn(), self.contents[typename].crsOptions)

        for s in srss:
            s = Crs(s)
            if srs.authority == s.authority and srs.code == s.code:
                if s.version and srs.version:
                    if s.version == srs.version:
                        idx = srss.index(s.getcodeurn())
                        return self.contents[typename].crsOptions[idx]
                else:
                    idx = srss.index(s.getcodeurn())
                    return self.contents[typename].crsOptions[idx]
        return None
예제 #6
0
    def getBBOXKVP (self,bbox,typename):
        """Formate bounding box for KVP request type (HTTP GET)

        @param bbox: (minx,miny,maxx,maxy[,srs])
        @type bbox: List
        @param typename:  feature name 
        @type typename: String
        @returns: String properly formated according to version and
            coordinate reference system
        """
        srs = None

        # srs of the bbox is specified in the bbox as fifth paramter
        if len(bbox) == 5:
            srs = Crs(bbox[4])
        # take default srs
        else:
            srs = self.contents[typename[0]].crsOptions[0]

        # 1.1.0 and 2.0.0 have same encoding
        if self.version in ["1.1.0","2.0.0"]:

            # format bbox parameter
            if srs.encoding == "urn" :
                    if srs.axisorder == "yx":
                        return "%s,%s,%s,%s,%s" % \
                            (bbox[1],bbox[0],bbox[3],bbox[2],srs.getcodeurn())
                    else:
                        return "%s,%s,%s,%s,%s" % \
                        (bbox[0],bbox[1],bbox[2],bbox[3],srs.getcodeurn())
            else:
                return "%s,%s,%s,%s,%s" % \
                        (bbox[0],bbox[1],bbox[2],bbox[3],srs.getcode())
        # 1.0.0
        else:
            return "%s,%s,%s,%s,%s" % \
                    (bbox[0],bbox[1],bbox[2],bbox[3],srs.getcode())