[GRASS-SVN] r65978 - in grass-addons/grass7/gui/wxpython/wx.metadata: db.csw.admin db.csw.harvest g.gui.cswbrowser g.gui.metadata mdlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Aug 20 06:18:14 PDT 2015
Author: krejcmat
Date: 2015-08-20 06:18:14 -0700 (Thu, 20 Aug 2015)
New Revision: 65978
Modified:
grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.admin/db.csw.admin.py
grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.harvest/db.csw.harvest.py
grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.cswbrowser/g.gui.cswbrowser.py
grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.py
grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdeditorfactory.py
grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdgrass.py
Log:
wx.metadata addons: fix epsg parser
Modified: grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.admin/db.csw.admin.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.admin/db.csw.admin.py 2015-08-20 13:04:31 UTC (rev 65977)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.admin/db.csw.admin.py 2015-08-20 13:18:14 UTC (rev 65978)
@@ -120,9 +120,8 @@
from grass.script import core as grass
+sys.path.insert(1, os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc', 'wx.metadata', 'mdlib'))
-sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'wx.metadata', 'mdlib'))
-
import getopt
from cswutil import *
Modified: grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.harvest/db.csw.harvest.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.harvest/db.csw.harvest.py 2015-08-20 13:04:31 UTC (rev 65977)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/db.csw.harvest/db.csw.harvest.py 2015-08-20 13:18:14 UTC (rev 65978)
@@ -9,7 +9,7 @@
(>=v2). Read the file COPYING that comes with GRASS for details.
@modified for GRASS GIS by Matej Krejci <matejkrejci gmail.com> (GSoC 2015)
- at originaly crated by "# Copyright (c) 2010 Tom Kralidis"
+ at originaly created by "# Copyright (c) 2010 Tom Kralidis"
@@ -49,7 +49,7 @@
import sys
import os
-sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'wx.metadata', 'mdlib'))
+sys.path.insert(1, os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc', 'wx.metadata', 'mdlib'))
from grass.script import core as grass
try:
@@ -124,7 +124,6 @@
harvest(options['source'], options['destination'])
-
if __name__ == "__main__":
options, flags = grass.parser()
main()
Modified: grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.cswbrowser/g.gui.cswbrowser.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.cswbrowser/g.gui.cswbrowser.py 2015-08-20 13:04:31 UTC (rev 65977)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.cswbrowser/g.gui.cswbrowser.py 2015-08-20 13:18:14 UTC (rev 65978)
@@ -13,12 +13,11 @@
import sys
import os
-sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'wx.metadata', 'mdlib'))
+sys.path.insert(1, os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc', 'wx.metadata', 'mdlib'))
import wx
from cswlib import CSWBrowserPanel, CSWConnectionPanel
import grass.script as grass
-
class CswBrowserMainDialog(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="Metadata browser", size=(1024, 760))
Modified: grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.py 2015-08-20 13:04:31 UTC (rev 65977)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.py 2015-08-20 13:18:14 UTC (rev 65978)
@@ -23,8 +23,8 @@
import sys
import os
-
sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc','wx.metadata','mdlib'))
+sys.path.insert(2, os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc', 'wx.metadata', 'mdlib'))
from lxml import etree
import wx
Modified: grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdeditorfactory.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdeditorfactory.py 2015-08-20 13:04:31 UTC (rev 65977)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdeditorfactory.py 2015-08-20 13:18:14 UTC (rev 65978)
@@ -946,7 +946,7 @@
'''note- exec cannot be in sub function
for easy understanding to product of self.generateGUI()- print stri
'''
- print stri
+ #print stri
exec stri
def plusC(self, num=None):
Modified: grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdgrass.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdgrass.py 2015-08-20 13:04:31 UTC (rev 65977)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdgrass.py 2015-08-20 13:18:14 UTC (rev 65978)
@@ -39,7 +39,8 @@
from datetime import date, datetime
from grass.script import core as grass
from osgeo import osr
-
+#sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc','wx.metadata','mdlib'))
+sys.path.insert(1, os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc', 'wx.metadata', 'mdlib'))
class GrassMD():
'''
@@ -184,38 +185,42 @@
self.md_abstract.translate("""&<>"'""")
def getEPSG(self):
- print 'epsg process'
proj=Module('g.proj',
flags='p',
quiet=True,
stdout_=PIPE)
+
proj=proj.outputs.stdout
- epsg=None
- for line in proj.splitlines():
+ lines=proj.splitlines()
+ for e,line in enumerate(lines):
if 'EPSG' in line:
- epsg=line.split(':')[1].replace(' ','')
+ epsg=lines[e+1].split(':')[1].replace(' ','')
return epsg
- try:
- proj=Module('g.proj',
+
+ proj=Module('g.proj',
flags='wf',
quiet=True,
stdout_=PIPE)
- proj=proj.outputs.stdout
- epsg=self.esriprj2standards(proj)
- print epsg
+ proj=proj.outputs.stdout
+
+ epsg = self.wkt2standards(proj)
+
+ if not epsg:
+ return None
+ else:
return epsg
+
+ def wkt2standards(self,prj_txt):
+ srs = osr.SpatialReference()
+ srs.ImportFromESRI([prj_txt])
+ srs.AutoIdentifyEPSG()
+ try :
+ int(srs.GetAuthorityCode(None))
+ return srs.GetAuthorityCode(None)
except:
+ grass.warning('Epsg code cannot be identified')
return None
- def esriprj2standards(self,prj_txt):
- srs = osr.SpatialReference()
- srs.ImportFromESRI([prj_txt])
- #print 'Shape prj is: %s' % prj_txt
- #print 'WKT is: %s' % srs.ExportToWkt()
- #print 'Proj4 is: %s' % srs.ExportToProj4()
- srs.AutoIdentifyEPSG()
- return srs.GetAuthorityCode(None)
-
def createTemporalISO(self, profile=None):
'''Create GRASS Temporal profile based on ISO
- unknown values are filling by n = '$NULL'
@@ -223,7 +228,7 @@
n = '$NULL'
# jinja templates
if profile is None:
- self.profilePath = os.path.join('profiles', 'temporalProfile.xml')
+ self.profilePath = os.path.join('etc','wx.metadata','profiles', 'temporalProfile.xml')
else:
self.profilePath = profile
self.schema_type = '_temporal.xml'
@@ -302,7 +307,7 @@
n = '$NULL'
# jinja templates
if profile is None:
- self.profilePath = os.path.join('profiles', 'basicProfile.xml')
+ self.profilePath = os.path.join('etc','wx.metadata','profiles', 'basicProfile.xml')
else:
self.profilePath = profile
@@ -347,7 +352,7 @@
self.md.referencesystem=MD_ReferenceSystem(None)
self.md.referencesystem.code='http://www.opengis.net/def/crs/EPSG/0/%s'%epsg
- print self.md.referencesystem.code
+ #print self.md.referencesystem.code
# Conformity/Date:
self.md.dataquality.conformancedate.append(mdutil.replaceXMLReservedChar(date.today().isoformat()))
self.md.dataquality.conformancedatetype.append('publication')
@@ -411,7 +416,7 @@
self.createGrassBasicISO()
if profile is None:
- self.profilePath = os.path.join('profiles', 'inspireProfile.xml')
+ self.profilePath = os.path.join('etc','wx.metadata','profiles', 'inspireProfile.xml')
else:
self.profilePath = profile
More information about the grass-commit
mailing list