本文整理汇总了Java中org.geotools.jdbc.JDBCDataStore类的典型用法代码示例。如果您正苦于以下问题:Java JDBCDataStore类的具体用法?Java JDBCDataStore怎么用?Java JDBCDataStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JDBCDataStore类属于org.geotools.jdbc包,在下文中一共展示了JDBCDataStore类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateGeometries
import org.geotools.jdbc.JDBCDataStore; //导入依赖的package包/类
/**
* Calculates the UrbanGrid area/perimeters for each Administrative area inside a separate thread.
*
* @param year Input ShapeFile year
* @param imperviousnessReference Input ShapeFile layer
* @param rois List of all the input Geometries
* @param numThreads Number of threads to lauch
* @param area Boolean indicating if area must be calculated. (Otherwise perimeter is calculated)
* @return
* @throws MalformedURLException
* @throws IOException
* @throws InterruptedException
*/
private List<ListContainer> calculateGeometries(String year, FeatureTypeInfo imperviousnessReference, List<Geometry> rois,
int numThreads, boolean area) throws MalformedURLException, IOException,
InterruptedException {
// Initialization of the CountDown latch for handling multiple threads together
latch = new CountDownLatch(numThreads);
// Datastore creation
final JDBCDataStore ds = (JDBCDataStore) imperviousnessReference.getStore().getDataStore(null);
// ThreadPoolExecutor object used for launching multiple threads simultaneously
ThreadPoolExecutor executor = new ThreadPoolExecutor(numThreads, numThreads, 60,
TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1000000));
// Final list containing the result calculated by each thread
List<ListContainer> allLists = new ArrayList<ListContainer>(numThreads);
// Cycle on the input geometries
for (Geometry geo : rois) {
// Creation of a new ListContainer object
ListContainer container = new ListContainer();
allLists.add(container);
// Creation of a new Runnable for the UrbanGrids computation
MyRunnable run = new MyRunnable(year, geo, imperviousnessReference, ds, container, area);
executor.execute(run);
}
// Waiting until all the threads have finished
latch.await();
// Executor closure
executor.shutdown();
executor.awaitTermination(30, TimeUnit.SECONDS);
// Datastore disposal
// ds.dispose();
return allLists;
}
示例2: SoilSealingAdministrativeUnit
import org.geotools.jdbc.JDBCDataStore; //导入依赖的package包/类
/**
* Default constructor
*
* @param au
* @param geoCodingReference
* @param populationReference
* @throws IOException
*/
public SoilSealingAdministrativeUnit(String au, FeatureTypeInfo geoCodingReference,
FeatureTypeInfo populationReference) throws IOException {
if (!au.contains("_")) {
throw new IOException("Invalid Administrative Unit name");
}
this.geoCodingReference = geoCodingReference;
this.populationReference = populationReference;
this.name = au.split("_")[0];
this.parent = au.split("_")[1];
FeatureReader<SimpleFeatureType, SimpleFeature> ftReader = null;
Transaction transaction = new DefaultTransaction();
try {
final JDBCDataStore ds = (JDBCDataStore) geoCodingReference.getStore().getDataStore(null);
Filter nameFilter = ff.equals(ff.property("name"), ff.literal(this.name));
Filter parentFilter = ff.equals(ff.property("parent"), ff.literal(this.parent));
Filter queryFilter = ff.and(Arrays.asList(nameFilter, parentFilter));
Query query = new Query(geoCodingReference.getFeatureType().getName().getLocalPart(), queryFilter);
ftReader = ds.getFeatureReader(query, transaction);
while (ftReader.hasNext()) {
Feature feature = ftReader.next();
this.type = AuType.getType((Integer) feature.getProperty("type").getValue());
this.the_geom = (Geometry) feature.getDefaultGeometryProperty().getValue();
break;
}
} finally {
if (ftReader != null) {
ftReader.close();
}
transaction.commit();
transaction.close();
}
if (this.type == null || this.the_geom == null) {
throw new IOException("Invalid Administrative Unit name: no record found!");
}
switch (this.type) {
case MUNICIPALITY:
loadPopulationStatistics(this);
break;
case DISTRICT:
case REGION:
loadSubs(this);
break;
default:
break;
}
}
示例3: loadPopulationStatistics
import org.geotools.jdbc.JDBCDataStore; //导入依赖的package包/类
/**
*
* @param soilSealingAdministrativeUnit
* @throws IOException
*/
private void loadPopulationStatistics(SoilSealingAdministrativeUnit soilSealingAdministrativeUnit) throws IOException {
FeatureReader<SimpleFeatureType, SimpleFeature> ftReader = null;
Transaction transaction = new DefaultTransaction();
try {
final JDBCDataStore ds = (JDBCDataStore) populationReference.getStore().getDataStore(null);
Filter auNameFilter = ff.equals(ff.property("au_name"), ff.literal(this.name));
Filter queryFilter = ff.and(Arrays.asList(auNameFilter));
Query query = new Query(populationReference.getFeatureType().getName().getLocalPart(), queryFilter);
ftReader = ds.getFeatureReader(query, transaction);
while (ftReader.hasNext()) {
Feature feature = ftReader.next();
Collection<Property> properties = feature.getProperties();
for (Property prop : properties) {
if (prop.getName().getLocalPart().startsWith("a_")) {
Object yearPopulationValue = prop.getValue();
if (yearPopulationValue != null) {
population.put(prop.getName().getLocalPart().split("a_")[1], ((BigDecimal) yearPopulationValue).intValue());
}
}
}
}
} finally {
if (ftReader != null) {
ftReader.close();
}
transaction.commit();
transaction.close();
}
}
示例4: createDataStoreInternal
import org.geotools.jdbc.JDBCDataStore; //导入依赖的package包/类
@Override
protected JDBCDataStore createDataStoreInternal(JDBCDataStore dataStore, Map params)
throws IOException {
// disable fetch size
// not fully supported by MonetDB
dataStore.setFetchSize(0);
return dataStore;
}
示例5: MonetDBDialect
import org.geotools.jdbc.JDBCDataStore; //导入依赖的package包/类
public MonetDBDialect(JDBCDataStore dataStore) {
super(dataStore);
}
示例6: createSQLDialect
import org.geotools.jdbc.JDBCDataStore; //导入依赖的package包/类
protected SQLDialect createSQLDialect(JDBCDataStore dataStore) {
return new MonetDBDialect(dataStore);
}
示例7: testCreateDataStore
import org.geotools.jdbc.JDBCDataStore; //导入依赖的package包/类
public void testCreateDataStore() throws Exception {
JDBCDataStore ds = factory.createDataStore( params );
assertNotNull( ds );
assertTrue(ds.getDataSource() instanceof ManageableDataSource);
ds.dispose();
}