X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=gis%2Fruntime%2Forg.argeo.gis.geotools%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fgeotools%2Fjcr%2FGeoJcrIndex.java;h=b9281b8229d1c9e19d1df22ebc1ea62e46fd4773;hb=c3be9f8db8a79e159d6a057758dfc7f3580efc2d;hp=b384eb3b69b0cdaabb085e7d01212a3c1a00139e;hpb=bf1f6b4f6cc4150a449b12a25256d2f8b3f803fb;p=lgpl%2Fargeo-commons.git 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 b384eb3b6..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>()); @@ -62,12 +68,16 @@ public class GeoJcrIndex implements EventListener, GisNames, GisTypes { // TODO: use common factory finder? private FilterFactory2 ff = new FilterFactoryImpl(); + /** Expects to execute with system authentication */ public void init() { - systemExecutionService.execute(new Runnable() { - public void run() { - initGeoJcrIndex(); - } - }); + if (systemExecutionService != null)// legacy + systemExecutionService.execute(new Runnable() { + public void run() { + initGeoJcrIndex(); + } + }); + else + initGeoJcrIndex(); } protected void initGeoJcrIndex() { @@ -174,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); @@ -291,8 +307,7 @@ public class GeoJcrIndex implements EventListener, GisNames, GisTypes { this.session = session; } - public void setSystemExecutionService( - Executor systemExecutionService) { + public void setSystemExecutionService(Executor systemExecutionService) { this.systemExecutionService = systemExecutionService; }