Example #1
0
 def Run(self):
     ogr2ogr = utf82locale(GSSCONF["OGR2OGR_APP"])
     command = " ".join(
         [ogr2ogr, " -f PostgreSQL ", self.connstr, self.layerpath])
     print command
     r = os.system(command)
     if r != 0:
         raise ToolRunFailErr(_("error"))
Example #2
0
 def GetOpenedLayersName(self):
     olayers = []
     item = self.layer_list.GetNextItem(-1, wx.LIST_NEXT_ALL,
                                        wx.LIST_STATE_DONTCARE)
     while item != -1:
         layerpath = utf82locale(self.layer_list.GetItem(item, 2).GetText())
         if layerpath != "" and layerpath != u"":
             olayers.append(layerpath)
         item = self.layer_list.GetNextItem(item, wx.LIST_NEXT_ALL,
                                            wx.LIST_STATE_DONTCARE)
     return olayers
Example #3
0
 def RunTool(self, layers, outSource, outName):
     if len(layers) == 1:
         layer = layers[0]
         tool = Ogr2ogr4intoMySQL(layer, outSource)
         if outName != "":
             tool.SetNewName(outName)
         #print self.chk_update.GetValue()
         if self.chk_update.GetValue():
             tool.SetUpdate()
         if self.chk_ow.GetValue():
             tool.SetOverWrite()
         if not self.chk_ow.GetValue():
             tool.SetBuildSpatialIndex(False)
         engine_txt = self.cb_engine.GetValue()
         if engine_txt != self.def_engine_txt and engine_txt != "":
             tool.SetEngine(utf82locale(engine_txt))
         tool.Run()
     else:
         PopMessage(E("layers count must be 1"))
Example #4
0
 def Run(self):
     ogr2ogr = utf82locale(GSSCONF["OGR2OGR_APP"])
     keymap = []
     createopts = []
     if self.engine is not None:
         createopts.append("ENGINE=" + self.engine)
     if not self.spatialIndex:
         createopts.append("SPATIAL_INDEX=NO")
     if self.rename is not None:
         keymap.append("-nln " + self.rename)
     if self.overwrite:
         keymap.append("-overwrite")
     if self.update:
         keymap.append("-update")
     lco = ""
     if len(createopts) > 0:
         lco = " -lco " + " ".join(createopts)
     command = " ".join([ogr2ogr, " -f MySQL ",self.connstr,self.layerpath, \
         " ".join(keymap), lco])
     print command
     r = os.system(command)
     if r != 0:
         raise ToolRunFailErr(_("error"))
Example #5
0
 def OnChar(self, evt):
     """键盘响应函数
     @type evt: wxEvent
     @param evt: 键盘响应事件
     """
     kp = KeyParser(evt)
     keycode = kp.keycode
     #print keycode
     if keycode == 27:  # escape
         self.parent.OutputMsg('')
         self.parent.EnableInput(False)
     elif keycode == 13:  # enter
         self.ordlist.append(self.GetValue())
         self.at = len(self.ordlist)
         msg = utf82locale(self.GetValue())
         self.parent.ExecMsg(msg)
         self.parent.EnableInput(False)
     elif keycode == 8:  # back
         if len(self.GetValue()) == 1:
             self.parent.EnableInput(False)
         else:
             evt.Skip(True)
     elif keycode == 9:  # tab
         self.SetValue(fillline.GetLine(self.GetValue()))
         self.SetInsertionPointEnd()
     elif keycode == 315:  # up
         if self.at >= 1:
             self.at -= 1
         self.SetValue(self.ordlist[self.at])
         self.SetInsertionPointEnd()
     elif keycode == 317:  # down
         if self.at + 1 < len(self.ordlist):
             self.at += 1
         self.SetValue(self.ordlist[self.at])
         self.SetInsertionPointEnd()
     else:
         evt.Skip(True)
Example #6
0
 def GetPath(self):
     """获取选择的路径
     @rtype: str
     @return: 路径
     """
     return utf82locale(self.dslist.GetStringSelection())
Example #7
0
        dataSource = layer.dataSource
        dataset = layer.DataSet()
        driver = dataSource.GetDriver()
        newds = driver.CreateDataSource(opath)
        layer2 = newds.CreateLayer(name, sr)
        lu = LayerUtil(layer)
        lu.CopyDataset(layer2)
        newds.Destroy()


def SetCoorSysByWkt(layer, wkt, opath):
    """为图层设置投影
    @type layer: Layer
    @param layer: 要设置投影的图层
    @type wkt: str
    @param wkt: 要设置的坐标系wkt表示
    @type opath: str 
    @param opath: 要输出的图层位置 
    """
    sr = osr.SpatialReference()
    sr.ImportFromWkt(wkt)
    SetCoorSys(layer, sr, opath)


if __name__ == "__main__":
    from geosings.core.system.EncodeTran import utf82locale
    layer = Layer.Open(utf82locale(u"J:/gisdata/GTIF/ping1.tif"))
    sr = osr.SpatialReference()
    sr.SetWellKnownGeogCS("WGS84")
    SetCoorSys(layer, sr, 'd:/gisdata')
Example #8
0
 def GetSelected(self):
     return utf82locale(self.thisds[1:])
Example #9
0
 def GetOutputName(self):
     return utf82locale(self.text_ctrl_2.GetValue())
Example #10
0
 def GetOutputSource(self):
     return utf82locale(self.text_ctrl_1.GetValue())