コード例 #1
0
ファイル: statusbar.py プロジェクト: starseeker/archival
 def ReprojectENToMap(self, e, n, useDefinedProjection):
     """Reproject east, north from user defined projection
     
     :param e,n: coordinate (for DMS string, else float or string)
     :param useDefinedProjection: projection defined by user in settings dialog
     
     @throws SbException if useDefinedProjection is True and projection is not defined in UserSettings
     """
     if useDefinedProjection:
         settings = UserSettings.Get(group='projection',
                                     key='statusbar',
                                     subkey='proj4')
         if not settings:
             raise SbException(
                 _("Projection not defined (check the settings)"))
         else:
             # reproject values
             projIn = settings
             projOut = RunCommand('g.proj', flags='jf', read=True)
             proj = projIn.split(' ')[0].split('=')[1]
             if proj in ('ll', 'latlong', 'longlat'):
                 e, n = utils.DMS2Deg(e, n)
                 proj, coord1 = utils.ReprojectCoordinates(coord=(e, n),
                                                           projIn=projIn,
                                                           projOut=projOut,
                                                           flags='d')
                 e, n = coord1
             else:
                 e, n = float(e), float(n)
                 proj, coord1 = utils.ReprojectCoordinates(coord=(e, n),
                                                           projIn=projIn,
                                                           projOut=projOut,
                                                           flags='d')
                 e, n = coord1
     elif self.mapFrame.GetMap().projinfo['proj'] == 'll':
         e, n = utils.DMS2Deg(e, n)
     else:
         e, n = float(e), float(n)
     return e, n
コード例 #2
0
    def ReprojectENToMap(self, e, n, useDefinedProjection):
        """Reproject east, north from user defined projection

        :param e,n: coordinate (for DMS string, else float or string)
        :param useDefinedProjection: projection defined by user in settings dialog

        @throws SbException if useDefinedProjection is True and projection is not defined in UserSettings
        """
        if useDefinedProjection:
            settings = UserSettings.Get(group="projection",
                                        key="statusbar",
                                        subkey="proj4")
            if not settings:
                raise SbException(
                    _("Projection not defined (check the settings)"))
            else:
                # reproject values
                projIn = settings
                projOut = RunCommand("g.proj", flags="jf", read=True)
                proj = projIn.split(" ")[0].split("=")[1]
                if proj in ("ll", "latlong", "longlat"):
                    e, n = utils.DMS2Deg(e, n)
                    proj, coord1 = utils.ReprojectCoordinates(coord=(e, n),
                                                              projIn=projIn,
                                                              projOut=projOut,
                                                              flags="d")
                    e, n = coord1
                else:
                    e, n = float(e), float(n)
                    proj, coord1 = utils.ReprojectCoordinates(coord=(e, n),
                                                              projIn=projIn,
                                                              projOut=projOut,
                                                              flags="d")
                    e, n = coord1
        elif self.mapFrame.GetMap().projinfo["proj"] == "ll":
            e, n = utils.DMS2Deg(e, n)
        else:
            e, n = float(e), float(n)
        return e, n