Esempio n. 1
0
    def addLayer(self, layerType):
        if layerType.hasGdalTMS():
            # create GDAL TMS layer
            layer = self.createGdalTmsLayer(layerType, layerType.displayName)
        else:
            # create OpenlayersLayer
            layer = OpenlayersLayer(self.iface, self._olLayerTypeRegistry)
            layer.setLayerName(layerType.displayName)
            layer.setLayerType(layerType)

        if layer.isValid():
            coordRefSys = layerType.coordRefSys(self.canvasCrs())
            self.setMapCrs(coordRefSys)
            QgsMapLayerRegistry.instance().addMapLayer(layer)

            # last added layer is new reference
            self.setReferenceLayer(layer)

            if not layerType.hasGdalTMS():
                msg = "Printing and rotating of Javascript API " \
                      "based layers is currently not supported!"
                self.iface.messageBar().pushMessage(
                    "OpenLayers Plugin",
                    msg,
                    level=QgsMessageBar.WARNING,
                    duration=5)
    def addLayer(self, layerType):
        layer = OpenlayersLayer(self.iface, self._olLayerTypeRegistry)
        layer.setLayerName(layerType.displayName)
        layer.setLayerType(layerType)
        if layer.isValid():
            coordRefSys = layerType.coordRefSys(self.canvasCrs())
            self.setMapCrs(coordRefSys)
            QgsMapLayerRegistry.instance().addMapLayer(layer)

            # last added layer is new reference
            self.setReferenceLayer(layer)
Esempio n. 3
0
    def addLayer(self, layerType):
        layer = OpenlayersLayer(self.iface, self._olLayerTypeRegistry)
        layer.setLayerName(layerType.displayName)
        layer.setLayerType(layerType)
        if layer.isValid():
            coordRefSys = layerType.coordRefSys(self.canvasCrs())
            self.setMapCrs(coordRefSys)
            QgsMapLayerRegistry.instance().addMapLayer(layer)

            # last added layer is new reference
            self.setReferenceLayer(layer)
  def addLayer(self, layerType):

    self.__setMapSrsGoogle()

    layer = OpenlayersLayer(self.iface, self.__coordRSGoogle, self.olLayerTypeRegistry)
    layer.setLayerName(layerType.name)
    layer.setLayerType(layerType)
    if layer.isValid():
      QgsMapLayerRegistry.instance().addMapLayer(layer)

      # last added layer is new reference
      self.setReferenceLayer(layer)
  def addLayer(self, layerType):
    # check layers
    mapCanvas = self.iface.mapCanvas()
    mapCanvas.mapRenderer().setProjectionsEnabled(True) 
    
    self.targetSRS = QgsCoordinateReferenceSystem(5181)   # Daum 5181
    if layerType.name.startswith('Naver'):
        self.targetSRS = QgsCoordinateReferenceSystem(5179)   # Naver 5179
        if mapCanvas.layerCount() == 0:
            mapCanvas.setExtent(QgsRectangle(90112, 1192896, 1990673, 2761664))
    else:
        if mapCanvas.layerCount() == 0:
            mapCanvas.setExtent(QgsRectangle(-30000, -60000, 494288, 988576))
        
    if QGis.QGIS_VERSION_INT >= 10900:
      mapCanvas.mapRenderer().setDestinationCrs(self.targetSRS)
    else:
      mapCanvas.mapRenderer().setDestinationSrs(self.targetSRS)
    mapCanvas.setMapUnits(self.targetSRS.mapUnits())
    
    # On the fly    
    if QGis.QGIS_VERSION_INT >= 10900:
      theCoodRS = mapCanvas.mapRenderer().destinationCrs()
    else:
      theCoodRS = mapCanvas.mapRenderer().destinationSrs()
    if theCoodRS != self.targetSRS:
      coodTrans = QgsCoordinateTransform(theCoodRS, self.targetSRS)
      extMap = mapCanvas.extent()
      extMap = coodTrans.transform(extMap, QgsCoordinateTransform.ForwardTransform)
      if QGis.QGIS_VERSION_INT >= 10900:
        mapCanvas.mapRenderer().setDestinationCrs(self.targetSRS)
      else:
        mapCanvas.mapRenderer().setDestinationSrs(self.targetSRS)
      mapCanvas.freeze(False)
      mapCanvas.setMapUnits(self.targetSRS.mapUnits())
      mapCanvas.setExtent(extMap)
      
    layer = OpenlayersLayer(self.iface, self.targetSRS, self.olLayerTypeRegistry)
    layer.setLayerName(layerType.name)
    layer.setLayerType(layerType)
    if layer.isValid():
      if QGis.QGIS_VERSION_INT >= 10900:
        QgsMapLayerRegistry.instance().addMapLayers([layer])
      else:
        QgsMapLayerRegistry.instance().addMapLayer(layer)

      # last added layer is new reference
      self.setReferenceLayer(layer)
    
    if QgsMapLayerRegistry.instance().count() == 1:
      mapCanvas = self.iface.mapCanvas()
      mapCanvas.setDirty(True)
      mapCanvas.refresh()
Esempio n. 6
0
    def addLayer(self, layerType):

        self.__setMapSrsGoogle()

        layer = OpenlayersLayer(self.iface, self.__coordRSGoogle,
                                self.olLayerTypeRegistry)
        layer.setLayerName(layerType.name)
        layer.setLayerType(layerType)
        if layer.isValid():
            QgsMapLayerRegistry.instance().addMapLayer(layer)

            # last added layer is new reference
            self.setReferenceLayer(layer)
  def addLayer(self, layerType):

    self.__setMapSrsGoogle()

    layer = OpenlayersLayer(self.iface, self.__coordRSGoogle, self.olLayerTypeRegistry)
    layer.setLayerName(layerType.name)
    layer.setLayerType(layerType)
    if layer.isValid():
      if QGis.QGIS_VERSION_INT >= 10900:
        QgsMapLayerRegistry.instance().addMapLayers([layer])
      else:
        QgsMapLayerRegistry.instance().addMapLayer(layer)

      # last added layer is new reference
      self.setReferenceLayer(layer)
Esempio n. 8
0
    def addLayer(self, layerType):

        self.__setMapSrsGoogle()

        layer = OpenlayersLayer(self.iface, self.__coordRSGoogle,
                                self.olLayerTypeRegistry)
        layer.setLayerName(layerType.name)
        layer.setLayerType(layerType)
        if layer.isValid():
            if QGis.QGIS_VERSION_INT >= 10900:
                QgsMapLayerRegistry.instance().addMapLayers([layer])
            else:
                QgsMapLayerRegistry.instance().addMapLayer(layer)

            # last added layer is new reference
            self.setReferenceLayer(layer)
    def addLayer(self, layerType, layerTreeGroup=None):
        layer = OpenlayersLayer(self.iface, self._olLayerTypeRegistry)
        layer.setLayerName(layerType.displayName)
        layer.setLayerType(layerType)
        if layer.isValid():
            coordRefSys = layerType.coordRefSys(self.canvasCrs())
            self.setMapCrs(coordRefSys)

            if layerTreeGroup:
                QgsMapLayerRegistry.instance().addMapLayer(layer, False)
                layerTreeGroup.insertChildNode(1, QgsLayerTreeLayer(layer))
            else:
                QgsMapLayerRegistry.instance().addMapLayer(layer)

            # last added layer is new reference
            self.setReferenceLayer(layer)
    def addLayer(self, layerType):
        if layerType.hasGdalTMS():
            # create GDAL TMS layer
            layer = self.createGdalTmsLayer(layerType, layerType.displayName)
        else:
            # create OpenlayersLayer
            layer = OpenlayersLayer(self.iface, self._olLayerTypeRegistry)
            layer.setLayerName(layerType.displayName)
            layer.setLayerType(layerType)

        if layer.isValid():
            coordRefSys = layerType.coordRefSys(self.canvasCrs())
            self.setMapCrs(coordRefSys)
            QgsMapLayerRegistry.instance().addMapLayer(layer)

            # last added layer is new reference
            self.setReferenceLayer(layer)
    def addLayer(self, layerType):
        if layerType.hasGdalTMS():
            # create GDAL TMS layer
            layer = self.createGdalTmsLayer(layerType, layerType.displayName)
        else:
            # create OpenlayersLayer
            layer = OpenlayersLayer(self.iface, self._olLayerTypeRegistry)
            layer.setLayerName(layerType.displayName)
            layer.setLayerType(layerType)

        if layer.isValid():
            coordRefSys = layerType.coordRefSys(self.canvasCrs())
            self.setMapCrs(coordRefSys)
            QgsMapLayerRegistry.instance().addMapLayer(layer)

            # last added layer is new reference
            self.setReferenceLayer(layer)
Esempio n. 12
0
    def addLayer(self, layerType):
        if layerType.hasGdalTMS():
            # create GDAL TMS layer
            layer = self.createGdalTmsLayer(layerType, layerType.displayName)
        else:
            # create OpenlayersLayer
            layer = OpenlayersLayer(self.iface, self._olLayerTypeRegistry)
            layer.setLayerName(layerType.displayName)
            layer.setLayerType(layerType)

        if layer.isValid():
            coordRefSys = layerType.coordRefSys(self.canvasCrs())
            self.setMapCrs(coordRefSys)
            QgsMapLayerRegistry.instance().addMapLayer(layer)

            # last added layer is new reference
            self.setReferenceLayer(layer)

            if not layerType.hasGdalTMS():
                msg = "Printing and rotating of Javascript API " \
                      "based layers is currently not supported!"
                self.iface.messageBar().pushMessage(
                    "OpenLayers Plugin", msg, level=QgsMessageBar.WARNING,
                    duration=5)
# -*- coding: utf-8 -*-