package org.geotools.data.geojson; /* * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * * (C) 2015, Open Source Geospatial Foundation (OSGeo) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import java.io.IOException; import org.geotools.data.FeatureReader; import org.geotools.data.FeatureWriter; import org.geotools.data.Query; import org.geotools.data.QueryCapabilities; import org.geotools.data.ResourceInfo; import org.geotools.data.Transaction; import org.geotools.data.store.ContentEntry; import org.geotools.data.store.ContentFeatureSource; import org.geotools.data.store.ContentFeatureStore; import org.geotools.data.store.ContentState; import org.geotools.geometry.jts.ReferencedEnvelope; import org.opengis.feature.FeatureVisitor; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; import org.opengis.feature.type.Name; import org.opengis.util.ProgressListener; public class GeoJSONFeatureStore extends ContentFeatureStore { public GeoJSONFeatureStore(ContentEntry entry, Query query) { super(entry, query); } @Override protected FeatureWriter<SimpleFeatureType, SimpleFeature> getWriterInternal(Query query, int flags) throws IOException { return new GeoJSONFeatureWriter(getState(), query); } GeoJSONFeatureSource delegate = new GeoJSONFeatureSource(entry, query) { @Override public void setTransaction(Transaction transaction) { super.setTransaction(transaction); GeoJSONFeatureStore.this.setTransaction(transaction); // Keep these two // implementations // on the same // transaction } }; @Override public void setTransaction(Transaction transaction) { super.setTransaction(transaction); if (delegate.getTransaction() != transaction) { delegate.setTransaction(transaction); } } @Override protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException { return delegate.getBoundsInternal(query); } @Override protected int getCountInternal(Query query) throws IOException { return delegate.getCountInternal(query); } @Override protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(Query query) throws IOException { return delegate.getReaderInternal(query); } @Override protected boolean handleVisitor(Query query, FeatureVisitor visitor) throws IOException { return delegate.handleVisitor(query, visitor); } @Override protected SimpleFeatureType buildFeatureType() throws IOException { return delegate.buildFeatureType(); } public GeoJSONDataStore getDataStore() { return delegate.getDataStore(); } public ContentEntry getEntry() { return delegate.getEntry(); } public Transaction getTransaction() { return delegate.getTransaction(); } public ContentState getState() { return delegate.getState(); } public ResourceInfo getInfo() { return delegate.getInfo(); } public Name getName() { return delegate.getName(); } public void accepts(Query query, FeatureVisitor visitor, ProgressListener progress) throws IOException { delegate.accepts(query, visitor, progress); } public QueryCapabilities getQueryCapabilities() { return delegate.getQueryCapabilities(); } }