From: Mathieu Baudier Date: Thu, 26 May 2011 15:38:37 +0000 (+0000) Subject: Fix how CRS is set in GeoTools X-Git-Tag: argeo-commons-2.1.30~1246 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=00ec568367442bfb51e506e73d3b9e8bd7798a1c;p=lgpl%2Fargeo-commons.git Fix how CRS is set in GeoTools NEW - bug 31: Add Swing based map viewer in RCP https://bugzilla.argeo.org/show_bug.cgi?id=31 git-svn-id: https://svn.argeo.org/commons/trunk@4541 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/gis/runtime/org.argeo.gis.geotools/src/main/java/org/argeo/geotools/jcr/GeoJcrIndex.java b/gis/runtime/org.argeo.gis.geotools/src/main/java/org/argeo/geotools/jcr/GeoJcrIndex.java index 7e4f28702..b9281b822 100644 --- a/gis/runtime/org.argeo.gis.geotools/src/main/java/org/argeo/geotools/jcr/GeoJcrIndex.java +++ b/gis/runtime/org.argeo.gis.geotools/src/main/java/org/argeo/geotools/jcr/GeoJcrIndex.java @@ -35,16 +35,20 @@ import org.geotools.feature.FeatureCollections; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.geotools.filter.FilterFactoryImpl; +import org.geotools.referencing.CRS; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; import org.opengis.filter.FilterFactory2; import org.opengis.filter.identity.FeatureId; +import org.opengis.referencing.FactoryException; +import org.opengis.referencing.NoSuchAuthorityCodeException; import org.opengis.referencing.crs.CoordinateReferenceSystem; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Polygon; +/** Index JCR nodes containing or referencing GIS data. */ public class GeoJcrIndex implements EventListener, GisNames, GisTypes { // PostGIS convention final static String DEFAULT_GEOM_NAME = "the_geom"; @@ -55,6 +59,8 @@ public class GeoJcrIndex implements EventListener, GisNames, GisTypes { private Session session; private Executor systemExecutionService; + private String crs = "EPSG:4326"; + /** The key is the workspace */ private Map> geoJcrIndexes = Collections .synchronizedMap(new HashMap>()); @@ -178,9 +184,15 @@ public class GeoJcrIndex implements EventListener, GisNames, GisTypes { } protected SimpleFeatureType getWorkspaceGeoJcrIndexType(String workspaceName) { + SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setNamespaceURI(GIS_NAMESPACE); builder.setName(workspaceName + "_geojcr_index"); + try { + builder.setCRS(CRS.decode(crs)); + } catch (Exception e) { + throw new ArgeoException("Cannot set CRS " + crs, e); + } builder.setDefaultGeometry(JcrUtils.normalize(GIS_BBOX)); builder.add(JcrUtils.normalize(GIS_BBOX), Polygon.class); diff --git a/gis/runtime/org.argeo.gis.geotools/src/main/java/org/argeo/geotools/jcr/SimpleGeoJcrMapper.java b/gis/runtime/org.argeo.gis.geotools/src/main/java/org/argeo/geotools/jcr/SimpleGeoJcrMapper.java index f7ac0df8a..27da93738 100644 --- a/gis/runtime/org.argeo.gis.geotools/src/main/java/org/argeo/geotools/jcr/SimpleGeoJcrMapper.java +++ b/gis/runtime/org.argeo.gis.geotools/src/main/java/org/argeo/geotools/jcr/SimpleGeoJcrMapper.java @@ -36,6 +36,7 @@ import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Polygon; +/** Maps geographical information meta data in a JCR repository. */ public class SimpleGeoJcrMapper implements GeoJcrMapper, GisNames { private final static Log log = LogFactory.getLog(SimpleGeoJcrMapper.class); @@ -277,6 +278,10 @@ public class SimpleGeoJcrMapper implements GeoJcrMapper, GisNames { + "' property"); return; } + + if (!systemSession.isLive()) + return; + String alias = properties.get(GeoToolsConstants.ALIAS_KEY); registeredDataStores.remove(alias); Node dataStoreNode = getDataStoreNode(systemSession, alias);