diff --git a/.gitignore b/.gitignore index 28061ac..5bceca3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,7 @@ env tests/dbexts.ini scripts site +.idea/ +*.iml +build/ +*.jython_cache \ No newline at end of file diff --git a/bin/geoscript b/bin/geoscript deleted file mode 100755 index d6f12da..0000000 --- a/bin/geoscript +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -JYTHON="" -if [ "$JYTHON_HOME" != "" ] && [ -e $JYTHON_HOME/jython ]; then - JYTHON=$JYTHON_HOME/bin/jython -else - which jython > /dev/null - if [ "$?" == "1" ]; then - echo "JYTHON_HOME not defined and jython not on the current PATH" - exit -1 - fi - JYTHON=`which jython` -fi - -export CLASSPATH=`geoscript-classpath` -$JYTHON diff --git a/bin/geoscript-py b/bin/geoscript-py new file mode 100755 index 0000000..a781b87 --- /dev/null +++ b/bin/geoscript-py @@ -0,0 +1,16 @@ +#!/bin/bash + +JYTHON="" +if [ "$JYTHON_HOME_DIR" != "" ] && [ -e $JYTHON_HOME_DIR/jython ]; then + JYTHON=$JYTHON_HOME/bin/jython +else + which jython > /dev/null + if [ "$?" == "1" ]; then + echo "JYTHON_HOME_DIR not defined and jython not on the current PATH" + exit -1 + fi + JYTHON=`which jython` +fi + +export CLASSPATH=`geoscript-py-classpath` +$JYTHON diff --git a/bin/geoscript-classpath b/bin/geoscript-py-classpath similarity index 100% rename from bin/geoscript-classpath rename to bin/geoscript-py-classpath diff --git a/bin/geoscript-py.bat b/bin/geoscript-py.bat new file mode 100644 index 0000000..c6da0f3 --- /dev/null +++ b/bin/geoscript-py.bat @@ -0,0 +1,32 @@ +@ECHO OFF + +REM SETLOCAL ENABLEDELAYEDEXPANSION + +REM ensure JYTHON_HOME_DIR set +IF NOT DEFINED JYTHON_HOME_DIR ( + GOTO NO_JYTHON_HOME +) + +REM ensure jython.bat can be found +SET JYTHON_EXE="%JYTHON_HOME_DIR%\jython.bat" +IF NOT EXIST %JYTHON_EXE% ( + GOTO NO_JYTHON +) + +REM run geoscript-classpath script +FOR /f "tokens=*" %%X IN ('%JYTHON_EXE% %~dp0geoscript-py-classpath') DO ( + SET CLASSPATH=%%X +) + +%JYTHON_EXE% +SET JYTHON_EXE= + +:NO_JYTHON_HOME +ECHO Error, JYTHON_HOME_DIR is unset. Please set JYTHON_HOME_DIR to root of Jython installation. +GOTO DONE + +:NO_JYTHON +ECHO Error, JYTHON_HOME_DIR was set but could not find 'jython' exe. +GOTO DONE + +:DONE diff --git a/bin/geoscript.bat b/bin/geoscript.bat deleted file mode 100644 index b5726a6..0000000 --- a/bin/geoscript.bat +++ /dev/null @@ -1,32 +0,0 @@ -@ECHO OFF - -REM SETLOCAL ENABLEDELAYEDEXPANSION - -REM ensure JYTHON_HOME set -IF NOT DEFINED JYTHON_HOME ( - GOTO NO_JYTHON_HOME -) - -REM ensure jython.bat can be found -SET JYTHON_EXE="%JYTHON_HOME%\jython.bat" -IF NOT EXIST %JYTHON_EXE% ( - GOTO NO_JYTHON -) - -REM run geoscript-classpath script -FOR /f "tokens=*" %%X IN ('%JYTHON_EXE% %~dp0geoscript-classpath') DO ( - SET CLASSPATH=%%X -) - -%JYTHON_EXE% -SET JYTHON_EXE= - -:NO_JYTHON_HOME -ECHO Error, JYTHON_HOME is unset. Please set JYTHON_HOME to root of Jython installation. -GOTO DONE - -:NO_JYTHON -ECHO Error, JYTHON_HOME was set but could not find 'jython' exe. -GOTO DONE - -:DONE diff --git a/doc/devel.rst b/doc/devel.rst index 0ca0584..92c7bd0 100644 --- a/doc/devel.rst +++ b/doc/devel.rst @@ -8,11 +8,11 @@ This section describes how to set up a GeoScript development environment. Install Jython -------------- -Jython version 2.5.1 or greater is required for GeoScript. +Jython version 2.7.2 or greater is required for GeoScript. * Install `Jython `_ - For the remainder of the document the Jython installation root will be referred to as ``JYTHON_HOME``. + For the remainder of the document the Jython installation root will be referred to as ``JYTHON_HOME_DIR``. Install setuptools ------------------ @@ -20,7 +20,7 @@ Install setuptools #. Downlaod `ez_setup.py `_ #. Execute :file:`ez_setup.py` with the :command:`jython` command:: - $ /bin/jython ez_setup.py + $ /bin/jython ez_setup.py Upon success :file:`/bin/easy_install` will be created. @@ -33,11 +33,11 @@ Install virtualenv #. Using :file:`easy_install` installed in the previous section easy install the virtualenv library:: - $ /bin/easy_install virtualenv + $ /bin/easy_install virtualenv #. Create a new virtualenv named ``geoscript``:: - $ /bin/virtualenv geoscript + $ /bin/virtualenv geoscript #. Activate the ``geoscript`` virtualenv:: @@ -102,7 +102,7 @@ GeoScript also requires a few Python dependencies. * Easy install py-dom-xpath:: - (geoscript)$ easy_install py-dom-xpath + (geoscript)$ easy_install py-dom-xpath-redux Install nose ------------ diff --git a/geoscript/__init__.py b/geoscript/__init__.py index 92ef8b6..7cedfc8 100644 --- a/geoscript/__init__.py +++ b/geoscript/__init__.py @@ -2,7 +2,6 @@ from java.lang import System try: - import org.geotools from org.geotools.util.factory import Hints # by default the geotools referenceing Systemtem assumes yx or lat/lon diff --git a/geoscript/geom/bounds.py b/geoscript/geom/bounds.py index 15a8618..eed9fa6 100644 --- a/geoscript/geom/bounds.py +++ b/geoscript/geom/bounds.py @@ -31,7 +31,7 @@ def __init__(self, west=None, south=None, east=None, north=None, prj=None, env=N ReferencedEnvelope.__init__(self) def getwest(self): - return self.minX() + return self.getMinX() west = property(getwest,None,None,'The leftmost/westmost oordinate of the bounds.') @@ -41,7 +41,7 @@ def get_l(self): l = property(get_l, None, None, "Use west.") def getsouth(self): - return self.minY() + return self.getMinY() south = property(getsouth,None,None,'The bottomtmost/southmost oordinate of the bounds.') @deprecated @@ -50,7 +50,7 @@ def get_b(self): b = property(get_b, None, None, "Use south.") def geteast(self): - return self.maxX() + return self.getMaxX() east = property(geteast,None,None,'The rightmost/eastmost oordinate of the bounds.') @deprecated @@ -59,7 +59,7 @@ def get_r(self): r = property(get_r, None, None, 'Use east.') def getnorth(self): - return self.maxY() + return self.getMaxY() north = property(getnorth,None,None,'The topmost/northmost oordinate of the bounds.') @deprecated diff --git a/geoscript/layer/layer.py b/geoscript/layer/layer.py index db50028..416c6a8 100644 --- a/geoscript/layer/layer.py +++ b/geoscript/layer/layer.py @@ -14,7 +14,7 @@ from org.geotools.data import Query, Transaction from org.geotools.factory import CommonFactoryFinder from org.geotools.util.factory import Hints -from org.geotools.feature import FeatureCollection, FeatureCollections +from org.geotools.feature import FeatureCollection, DefaultFeatureCollection from org.opengis.filter.sort import SortOrder _filterFactory = CommonFactoryFinder.getFilterFactory(None) @@ -162,7 +162,7 @@ def bounds(self, filter=None): fc = self._source.getFeatures(q) e = fc.getBounds() if e: - if e.crs(): + if e.getCoordinateReferenceSystem(): return geom.Bounds(env=e) else: return geom.Bounds(env=e, prj=self.proj) @@ -367,7 +367,7 @@ def add(self, o): elif isinstance(o, (dict,list)): f = self.schema.feature(o) - fc = FeatureCollections.newCollection() + fc = DefaultFeatureCollection() fc.add(f._feature) self._source.addFeatures(fc) diff --git a/geoscript/render/base.py b/geoscript/render/base.py index 211f4b3..524bf6a 100644 --- a/geoscript/render/base.py +++ b/geoscript/render/base.py @@ -3,7 +3,7 @@ from geoscript import geom, proj, style from geoscript.layer import Raster from org.geotools.geometry.jts import ReferencedEnvelope -from org.geotools.map import DefaultMapContext, DefaultMapLayer +from org.geotools.map import MapContent, FeatureLayer, GridCoverageLayer from org.geotools.renderer.lite import StreamingRenderer class RendererBase: @@ -12,13 +12,16 @@ class RendererBase: """ def render(self, layers, styles, bounds, size, **options): - self.map = DefaultMapContext(bounds.proj._crs) - self.map.setAreaOfInterest(bounds) + self.map = MapContent() + self.map.getViewport().setCoordinateReferenceSystem(bounds.proj._crs) + self.map.getViewport().setBounds(bounds) for i in range(len(layers)): - l = layers[i] + l = layers[i] + data = l._coverage if isinstance(l,Raster) else l._source - self.map.addLayer(DefaultMapLayer(data, styles[i]._style())) + mapLayer = GridCoverageLayer(data, styles[i]._style()) if isinstance(l,Raster) else FeatureLayer(data, styles[i]._style()) + self.map.addLayer(mapLayer) w,h = (size[0], size[1]) @@ -27,7 +30,7 @@ def render(self, layers, styles, bounds, size, **options): renderer = StreamingRenderer() renderer.setJava2DHints(awt.RenderingHints(hints)) - renderer.setContext(self.map) + renderer.setMapContent(self.map) img = image.BufferedImage(w, h, image.BufferedImage.TYPE_INT_ARGB) g = img.getGraphics() diff --git a/geoscript/render/mapwindow.py b/geoscript/render/mapwindow.py index d7cf374..12d3034 100644 --- a/geoscript/render/mapwindow.py +++ b/geoscript/render/mapwindow.py @@ -3,7 +3,7 @@ from javax import swing from geoscript import geom, proj, style from org.geotools.geometry.jts import ReferencedEnvelope -from org.geotools.map import DefaultMapContext, DefaultMapLayer +from org.geotools.map import MapContent, Layer from org.geotools.renderer.lite import StreamingRenderer from org.geotools.swing import JMapPane from org.geotools.swing.action import * @@ -20,11 +20,12 @@ def __init__(self): pass def render(self, layers, styles, bounds, size, **options): - self.map = DefaultMapContext(bounds.proj._crs) - self.map.setAreaOfInterest(bounds) + self.map = MapContent() + self.map.getViewport().setCoordinateReferenceSystem(bounds.proj._crs) + self.map.getViewport().setBounds(bounds) for i in range(len(layers)): - self.map.addLayer(DefaultMapLayer(layers[i]._source,styles[i]._style())) + self.map.addLayer(Layer(layers[i]._source,styles[i]._style())) w,h = (size[0], size[1]) diff --git a/geoscript/style/icon.py b/geoscript/style/icon.py index e2e5638..b3391d8 100644 --- a/geoscript/style/icon.py +++ b/geoscript/style/icon.py @@ -1,4 +1,5 @@ import mimetypes +import mimetypes from geoscript.util import toURL from geoscript.style import util from geoscript.style.symbolizer import Symbolizer @@ -37,7 +38,7 @@ def _apply(self, sym): g = util.graphic(sym) if self.size: g.size = self.size.expr - g.setMarks([]) + g.graphicalSymbols().clear() if g: g.graphicalSymbols().add(eg) diff --git a/geoscript/style/stroke.py b/geoscript/style/stroke.py index 18df19e..b01fd9e 100644 --- a/geoscript/style/stroke.py +++ b/geoscript/style/stroke.py @@ -93,7 +93,7 @@ def interpolate(self, stroke, n=10, method='linear'): def _prepare(self, rule): sym = self.factory.createLineSymbolizer() self._apply(sym) - rule.addSymbolizer(sym) + rule.symbolizers().add(sym) def _apply(self, sym): Symbolizer._apply(self, sym) diff --git a/geoscript/style/symbolizer.py b/geoscript/style/symbolizer.py index 6eb3716..bc2d139 100644 --- a/geoscript/style/symbolizer.py +++ b/geoscript/style/symbolizer.py @@ -93,7 +93,7 @@ def _style(self): for fil in ftbl.keys(): syms = ftbl[fil] rule = self.factory.createRule() - fts.addRule(rule) + fts.rules().add(rule) if scale[0] > -1: rule.setMinScaleDenominator(scale[0]) if scale[1] > -1: diff --git a/pom.xml b/pom.xml index fdb1e0e..36cf4e5 100644 --- a/pom.xml +++ b/pom.xml @@ -1,326 +1,330 @@ - 4.0.0 - org.geoscript - geoscript-py - jar - 1.5-SNAPSHOT - GeoScript Python - - - - osgeo-releases - OSGeo Nexus Release Repository - https://repo.osgeo.org/repository/release/ - - false - - - true - - - - osgeo-snapshots - OSGeo Nexus Snapshot Repository - https://repo.osgeo.org/repository/snapshot/ - - true - - - false - - - - - - - nexus - OSGeo Release Repository - https://repo.osgeo.org/repository/geotools-releases/ - false - - - nexus - false - OSGeo Snapshot Repository - https://repo.osgeo.org/repository/geotools-snapshots/ - - - - - - org.geotools - gt-main - ${gt.version} - - - org.geotools - gt-epsg-hsql - ${gt.version} - - - org.geotools - gt-render - ${gt.version} - - - org.geotools - gt-shapefile - ${gt.version} - - - org.geotools.jdbc - gt-jdbc-postgis - ${gt.version} - - - org.geotools.jdbc - gt-jdbc-h2 - ${gt.version} - - - org.geotools.jdbc - gt-jdbc-mysql - ${gt.version} - - - org.geotools.jdbc - gt-jdbc-teradata - ${gt.version} - - - org.geotools - gt-property - ${gt.version} - - - - org.geotools.xsd - gt-xsd-wfs - ${gt.version} - - - org.geotools.xsd - gt-xsd-kml - ${gt.version} - - - org.geotools - gt-geojson - ${gt.version} - - - org.geotools - gt-charts - ${gt.version} - - - org.geotools - gt-swing - ${gt.version} - - - org.geotools - gt-svg - ${gt.version} - - - org.geotools - gt-process-geometry - ${gt.version} - - - org.geotools - gt-process-feature - ${gt.version} - - - org.geotools - gt-process-raster - ${gt.version} - - - org.geotools - gt-geotiff - ${gt.version} - - - org.geotools - gt-image - ${gt.version} - - - org.geotools - gt-imagemosaic - ${gt.version} - - - org.geotools - gt-imageio-ext-gdal - ${gt.version} - - - org.geotools - gt-geopkg - ${gt.version} - - - jython - jython - 2.5.2 - provided - - - - - - - java - - - ${basedir} - - geoscript/**/*.py - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.6 - 1.6 - true - UTF-8 - - - - - maven-dependency-plugin - - ${basedir}/jars - provided - - - - install - - copy-dependencies - - - - - - maven-antrun-plugin - 1.8 - - - initialize - initialize - - - - - - - run - - - - package-jars - package - - - - - - - run - - - - clean - clean - - - - - - - run - - - - - - - - org.apache.maven.wagon - wagon-webdav - 1.0-beta-2 - - - - - - - - oracle - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + org.geoscript + geoscript-py + jar + 1.5-SNAPSHOT + GeoScript Python + + + osgeo-releases + OSGeo Nexus Release Repository + https://repo.osgeo.org/repository/release/ + + false + + + true + + + + osgeo-snapshots + OSGeo Nexus Snapshot Repository + https://repo.osgeo.org/repository/snapshot/ + + true + + + false + + + + + + nexus + OSGeo Release Repository + https://repo.osgeo.org/repository/geotools-releases/ + false + + + nexus + false + OSGeo Snapshot Repository + https://repo.osgeo.org/repository/geotools-snapshots/ + + + - org.geotools.jdbc - gt-jdbc-oracle - ${gt.version} + org.geotools + gt-main + ${gt.version} - com.oracle - ojdbc14 - 10.2.0.3.0 + org.geotools + gt-epsg-hsql + ${gt.version} - - - - spatialite - - org.geotools.jdbc - gt-jdbc-spatialite - ${gt.version} + org.geotools + gt-render + ${gt.version} - - - - - - 22.0 - - + + org.geotools + gt-shapefile + ${gt.version} + + + org.geotools.jdbc + gt-jdbc-postgis + ${gt.version} + + + org.geotools.jdbc + gt-jdbc-h2 + ${gt.version} + + + org.geotools.jdbc + gt-jdbc-mysql + ${gt.version} + + + org.geotools.jdbc + gt-jdbc-teradata + ${gt.version} + + + org.geotools + gt-property + ${gt.version} + + + org.geotools.xsd + gt-xsd-wfs + ${gt.version} + + + org.geotools.xsd + gt-xsd-kml + ${gt.version} + + + org.geotools + gt-geojson + ${gt.version} + + + org.geotools + gt-charts + ${gt.version} + + + org.geotools + gt-swing + ${gt.version} + + + org.geotools + gt-svg + ${gt.version} + + + org.geotools + gt-process-geometry + ${gt.version} + + + org.geotools + gt-process-feature + ${gt.version} + + + org.geotools + gt-process-raster + ${gt.version} + + + org.geotools + gt-geotiff + ${gt.version} + + + org.geotools + gt-image + ${gt.version} + + + org.geotools + gt-imagemosaic + ${gt.version} + + + org.geotools + gt-imageio-ext-gdal + ${gt.version} + + + org.geotools + gt-geopkg + ${gt.version} + + + org.python + jython-standalone + 2.7.2 + + + + java + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + true + UTF-8 + + + + maven-dependency-plugin + 3.1.2 + + ${basedir}/jars + jython-standalone + + + + install + + copy-dependencies + + + + + + maven-antrun-plugin + 1.8 + + + initialize + initialize + + + + + + + run + + + + package-jars + package + + + + + + + run + + + + clean + clean + + + + + + + run + + + + + + maven-resources-plugin + 3.1.0 + + + copy-resources + validate + + copy-resources + + + ${basedir}/target/classes/Lib + + + ${basedir}/geoscript + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.3 + + + package + + shade + + + geoscript-py-app-${project.version} + true + + + META-INF/spring.handlers + + + META-INF/spring.schemas + + + org.python.util.jython + + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + + org.apache.maven.wagon + wagon-webdav + 1.0-beta-2 + + + + + + oracle + + + org.geotools.jdbc + gt-jdbc-oracle + ${gt.version} + + + com.oracle + ojdbc14 + 10.2.0.3.0 + + + + + + 22.0 + diff --git a/setup.py b/setup.py index a9012a2..043f92b 100644 --- a/setup.py +++ b/setup.py @@ -44,9 +44,9 @@ def run(self): description='GeoScript Python', author='Justin Deoliveira', author_email='jdeolive@opengeo.org', - url='http://geoscript.org', + url='http://geoscript.net', packages=find_packages(), data_files=[('jars', jars)], - scripts=['bin/geoscript-classpath', 'bin/geoscript', 'bin/geoscript.bat'] + scripts=['bin/geoscript-py-classpath', 'bin/geoscript-py', 'bin/geoscript-py.bat'] ) diff --git a/tests/layer/test_geotiff.py b/tests/layer/test_geotiff.py index 33b41c2..86d1e70 100644 --- a/tests/layer/test_geotiff.py +++ b/tests/layer/test_geotiff.py @@ -8,7 +8,7 @@ def setUp(self): def testBounds(self): assert self.tif.bounds() is not None - assert self.tif.bounds().west == 589980.0 + assert self.tif.bounds().getwest() == 589980.0 assert self.tif.bounds().south == 4913700.0 assert self.tif.bounds().east == 609000.0 assert self.tif.bounds().north == 4928010.0