本文整理汇总了Java中org.geotools.factory.GeoTools类的典型用法代码示例。如果您正苦于以下问题:Java GeoTools类的具体用法?Java GeoTools怎么用?Java GeoTools使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeoTools类属于org.geotools.factory包,在下文中一共展示了GeoTools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: choose
import org.geotools.factory.GeoTools; //导入依赖的package包/类
/**
* Get user to choose raster format.
*
* @param rasterFile the raster file
* @param selectionPanel the selection panel
* @return the abstract grid format
*/
public static AbstractGridFormat choose(File rasterFile,
ChooseRasterFormatInterface selectionPanel) {
if (rasterFile != null) {
final Set<AbstractGridFormat> formats = GridFormatFinder.findFormats(rasterFile,
GeoTools.getDefaultHints());
if (formats.size() > 1) {
if (selectionPanel != null) {
AbstractGridFormat selectedFormat = selectionPanel.showPanel(formats);
if (selectedFormat != null) {
return selectedFormat;
}
}
}
// otherwise just pick the first
final Iterator<AbstractGridFormat> it = formats.iterator();
if (it.hasNext()) {
return it.next();
}
}
return new UnknownFormat();
}
示例2: splashText
import org.geotools.factory.GeoTools; //导入依赖的package包/类
/**
* Splash text.
*
* @param str the str
*/
public static void splashText(final String str) {
logger.info(str);
if (splashScreenObj != null && splashScreenObj.isVisible()) {
// draw the text
splashGraphics.setPaint(Color.BLACK);
splashGraphics.setFont(getFont());
splashGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
splashGraphics.setColor(Color.black);
splashGraphics.drawString(str, (int) getTextPosition().getX(),
(int) getTextPosition().getY());
String geoToolsVersionString = String.format("%s GeoTools %s",
Localisation.getString(AboutDialog.class, "AboutDialog.basedOn"),
GeoTools.getVersion().toString());
splashGraphics.drawString(geoToolsVersionString, (int) getTextPosition().getX(),
(int) (getTextPosition().getY() + AppSplashScreen.getFont().getSize2D()));
// make sure it's displayed
splashScreenObj.update();
}
}
示例3: createTextList
import org.geotools.factory.GeoTools; //导入依赖的package包/类
/**
* Creates the text list.
*
* @return the list
*/
private List<TextPosition> createTextList() {
List<TextPosition> textList = new ArrayList<TextPosition>();
// Application version string
Point textPosition = AppSplashScreen.getTextPosition();
textList.add(new TextPosition(AppSplashScreen.getVersionString(), textPosition));
// GeoTools version string
Point p = new Point((int) textPosition.getX(),
(int) (textPosition.getY() + AppSplashScreen.getFont().getSize2D()));
String geoToolsVersionString = String.format("%s GeoTools %s",
Localisation.getString(AboutDialog.class, "AboutDialog.basedOn"),
GeoTools.getVersion().toString());
textList.add(new TextPosition(geoToolsVersionString, p));
return textList;
}
示例4: removeExample
import org.geotools.factory.GeoTools; //导入依赖的package包/类
private void removeExample() throws Exception {
// removeExample start
Transaction transaction = new DefaultTransaction("removeExample");
SimpleFeatureStore store = (SimpleFeatureStore) dataStore.getFeatureSource(typeName);
store.setTransaction(transaction);
FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
Filter filter = ff.id(Collections.singleton(ff.featureId("fred")));
try {
store.removeFeatures(filter);
transaction.commit();
} catch (Exception eek) {
transaction.rollback();
}
// removeExample end
}
示例5: removeExample2
import org.geotools.factory.GeoTools; //导入依赖的package包/类
private void removeExample2() throws Exception {
// removeExample2 start
Transaction transaction = new DefaultTransaction("removeExample");
SimpleFeatureStore store = (SimpleFeatureStore) dataStore.getFeatureSource(typeName);
store.setTransaction(transaction);
FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
Filter filter = ff.id(Collections.singleton(ff.featureId("fred")));
try {
final Set<FeatureId> removed = new HashSet<FeatureId>();
SimpleFeatureCollection collection = store.getFeatures( new Query( typeName, filter, Query.NO_NAMES ));
collection.accepts( new FeatureVisitor(){
public void visit(Feature feature) {
removed.add( feature.getIdentifier() );
}
}, null );
store.removeFeatures(filter);
transaction.commit();
} catch (Exception eek) {
transaction.rollback();
}
// removeExample2 end
}
示例6: GeoWaveGTDataStoreFactory
import org.geotools.factory.GeoTools; //导入依赖的package包/类
/**
* Public "no argument" constructor called by Factory Service Provider (SPI)
* entry listed in META-INF/services/org.geotools.data.DataStoreFactorySPI
*/
public GeoWaveGTDataStoreFactory() {
final Collection<StoreFactoryFamilySpi> dataStoreFactories = GeoWaveStoreFinder
.getRegisteredStoreFactoryFamilies()
.values();
if (dataStoreFactories.isEmpty()) {
LOGGER.error("No GeoWave DataStore found! Geotools datastore for GeoWave is unavailable");
geowaveStoreFactoryFamily = null;
}
else {
final Iterator<StoreFactoryFamilySpi> it = dataStoreFactories.iterator();
geowaveStoreFactoryFamily = it.next();
if (it.hasNext()) {
GeoTools.addFactoryIteratorProvider(new GeoWaveGTDataStoreFactoryIteratorProvider());
}
}
}
示例7: execute
import org.geotools.factory.GeoTools; //导入依赖的package包/类
@DescribeResult(name = "result", description = "This is just a pass-through, the key is to provide enough information within invertQuery to perform a map to screen transform")
public GridCoverage2D execute(
@DescribeParameter(name = "data", description = "Feature collection containing the rendered image")
final SimpleFeatureCollection features )
throws ProcessException {
// vector-to-raster render transform that take a single feature that
// wraps a distributed render result and converts it to a GridCoverage2D
if (features != null) {
final SimpleFeatureIterator it = features.features();
if (it.hasNext()) {
final SimpleFeature resultFeature = features.features().next();
final DistributedRenderResult actualResult = (DistributedRenderResult) resultFeature.getAttribute(0);
final DistributedRenderOptions renderOptions = (DistributedRenderOptions) resultFeature.getAttribute(1);
// convert to the GridCoverage2D required for output
final GridCoverageFactory gcf = CoverageFactoryFinder
.getGridCoverageFactory(GeoTools.getDefaultHints());
final BufferedImage result = actualResult.renderComposite(renderOptions);
final GridCoverage2D gridCov = gcf.create(
"Process Results",
result,
renderOptions.getEnvelope());
return gridCov;
}
}
return null;
}
示例8: createRules
import org.geotools.factory.GeoTools; //导入依赖的package包/类
private static Rule[] createRules(String parameter,
StyleBuilder styleBuilder, double[] breaks, Color[] colors,
FeatureType type) {
FilterFactory filterFactory = CommonFactoryFinder
.getFilterFactory(GeoTools.getDefaultHints());
Rule[] rules = new Rule[breaks.length];
for (int i = 0; i < breaks.length; i++) {
Symbolizer symbolizer = createSymbolizer(styleBuilder, colors[i],
type);
Rule rule = styleBuilder.createRule(symbolizer);
Expression property = filterFactory.property(parameter);
Filter filter = filterFactory.lessOrEqual(property,
filterFactory.literal(breaks[i]));
if (i > 0) {
Filter greater = filterFactory.greater(property,
filterFactory.literal(breaks[i - 1]));
filter = filterFactory.and(filter, greater);
}
rule.setFilter(filter);
rules[i] = rule;
}
return rules;
}
示例9: openInputShapefile
import org.geotools.factory.GeoTools; //导入依赖的package包/类
/**
* Open the input shape file and load it into memory.
*/
public void openInputShapefile(String inputShapefile) throws IOException {
File file = new File(inputShapefile);
ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
Map<String, Serializable> params = new HashMap<>();
params.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL());
params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, Boolean.TRUE);
params.put(ShapefileDataStoreFactory.ENABLE_SPATIAL_INDEX.key, Boolean.TRUE);
params.put(ShapefileDataStoreFactory.MEMORY_MAPPED.key, Boolean.TRUE);
params.put(ShapefileDataStoreFactory.CACHE_MEMORY_MAPS.key, Boolean.TRUE);
ShapefileDataStore store = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);
featureSource = store.getFeatureSource();
// determine the correct case of the tz attribute because its case has been
// changed from efele to evansiroky
SimpleFeatureType schema = featureSource.getSchema();
List<AttributeDescriptor> attributeDescriptorList = schema.getAttributeDescriptors();
for (AttributeDescriptor attributeDescriptor : attributeDescriptorList) {
if ("tzid".equalsIgnoreCase(attributeDescriptor.getLocalName())) {
tzidAttr = attributeDescriptor.getLocalName();
}
}
filterFactory = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
geometryFactory = JTSFactoryFinder.getGeometryFactory();
}
示例10: getOWIVersion
import org.geotools.factory.GeoTools; //导入依赖的package包/类
@Override
public Map<String, String> getOWIVersion() {
LOGGER.info("Using version: " + WifKeys.WIF_KEY_VERSION);
LOGGER.info("Spring version: {} ", SpringVersion.getVersion());
LOGGER.info("GeoTools version: {} ", GeoTools.getVersion());
// LOGGER.info("Datastore client version: {} ",
// dataStoreClient.getVersion());
versionsMap.put("What-If API", WifKeys.WIF_KEY_VERSION);
versionsMap.put("Spring", SpringVersion.getVersion());
versionsMap.put("Geotools", GeoTools.getVersion().toString());
versionsMap.put("DatastoreClient", "N/A");
return versionsMap;
}
示例11: ClassifiedStyleCreator
import org.geotools.factory.GeoTools; //导入依赖的package包/类
public ClassifiedStyleCreator() {
Set<Function> funcs = CommonFactoryFinder.getFunctions(GeoTools
.getDefaultHints());
ArrayList<String> fNames = new ArrayList<String>();
for (Function func : funcs) {
if (func instanceof ClassificationFunction) {
classifiers.add(func);
fNames.add(func.getName());
}
}
setPalette(DEFAULT_PALETTE);
setNumberOfClasses(DEFAULT_NUMBER_OF_CLASSES);
setClassifier(DEFAULT_CLASSIFIER);
}
示例12: testExactUpScale
import org.geotools.factory.GeoTools; //导入依赖的package包/类
@Test
public void testExactUpScale() {
float[][] grid = new float[][] {{1,2},{3,4}};
final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 4, 4);
final RenderedImage renderedImage = scaled.getRenderedImage();
assertEquals(4, renderedImage.getWidth());
assertEquals(4, renderedImage.getHeight());
float[][] expected = new float[][] {{1,1,2,2},{1,1,2,2},{3,3,4,4},{3,3,4,4}};
IntStream.range(0,4).forEach(i->IntStream.range(0, 4).forEach(j -> {
float actual = scaled.evaluate(new GridCoordinates2D(j,i), new float[1])[0];
assertEquals(expected[i][j], actual, 1e-10);
}));
}
示例13: testExactDownScale
import org.geotools.factory.GeoTools; //导入依赖的package包/类
@Test
public void testExactDownScale() {
float[][] grid = new float[][] {{1,1,2,2},{1,1,2,2},{3,3,4,4},{3,3,4,4}};
final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 2,2);
final RenderedImage renderedImage = scaled.getRenderedImage();
assertEquals(2, renderedImage.getWidth());
assertEquals(2, renderedImage.getHeight());
float[][] expected = new float[][] {{1,2},{3,4}};
IntStream.range(0,2).forEach(i->IntStream.range(0, 2).forEach(j -> {
float actual = scaled.evaluate(new GridCoordinates2D(j,i), new float[1])[0];
assertEquals(expected[i][j], actual, 1e-10);
}));
}
示例14: testInexactScale
import org.geotools.factory.GeoTools; //导入依赖的package包/类
@Test
public void testInexactScale() {
float[][] grid = new float[][] {{1,2},{3,4}};
final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 3, 7);
final RenderedImage renderedImage = scaled.getRenderedImage();
assertEquals(7, renderedImage.getWidth());
assertEquals(3, renderedImage.getHeight());
}
示例15: testSmallScale
import org.geotools.factory.GeoTools; //导入依赖的package包/类
@Test
public void testSmallScale() {
float[][] grid = new float[1500][1500];
final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 1501, 1499);
final RenderedImage renderedImage = scaled.getRenderedImage();
assertEquals(1499, renderedImage.getWidth());
assertEquals(1501, renderedImage.getHeight());
}