org.geotools.factory.Hints Java Examples

The following examples show how to use org.geotools.factory.Hints. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WKTConversion.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/** Initialise the WKTParser object. */
private static void initialise() {
    Hints hints = new Hints(Hints.CRS, DefaultGeographicCRS.WGS84);

    PositionFactory positionFactory = GeometryFactoryFinder.getPositionFactory(hints);
    GeometryFactory geometryFactory = GeometryFactoryFinder.getGeometryFactory(hints);
    PrimitiveFactory primitiveFactory = GeometryFactoryFinder.getPrimitiveFactory(hints);
    AggregateFactory aggregateFactory = GeometryFactoryFinder.getAggregateFactory(hints);

    wktParser =
            new WKTParser(geometryFactory, primitiveFactory, positionFactory, aggregateFactory);

    wktTypeList.add(new WKTType(WKT_POINT, false, 1, "Point", false, false));
    wktTypeList.add(new WKTType(WKT_MULTIPOINT, true, 1, "Point", true, false));
    wktTypeList.add(new WKTType(WKT_LINESTRING, false, 2, "Line", false, false));
    wktTypeList.add(new WKTType("LINEARRING", false, 2, "Line", false, false));
    wktTypeList.add(new WKTType(WKT_MULTILINESTRING, true, 2, "Line", true, false));
    wktTypeList.add(new WKTType(WKT_POLYGON, false, -1, "Polygon", false, true));
    wktTypeList.add(new WKTType(WKT_MULTIPOLYGON, true, -1, "Polygon", true, true));

    for (WKTType wkyType : wktTypeList) {
        wktTypeMap.put(wkyType.getName(), wkyType);
    }
}
 
Example #2
Source File: ImageServiceMapTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testGraphics2D() throws Exception {
	ClientMapInfo mapInfo = new ClientMapInfo();
	MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
	mapRasterizingInfo.setBounds(new Bbox(-80, -50, 100, 100));
	mapInfo.setCrs("EPSG:4326");
	mapRasterizingInfo.setScale(1);
	mapRasterizingInfo.setTransparent(true);
	mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);
	ClientVectorLayerInfo clientBeansPointLayerInfo = new ClientVectorLayerInfo();
	clientBeansPointLayerInfo.setServerLayerId(layerBeansPoint.getId());
	VectorLayerRasterizingInfo layerRasterizingInfo = new VectorLayerRasterizingInfo();
	layerRasterizingInfo.setStyle(layerBeansPointStyleInfo);
	clientBeansPointLayerInfo.getWidgetInfo().put(VectorLayerRasterizingInfo.WIDGET_KEY, layerRasterizingInfo);
	mapInfo.getLayers().add(clientBeansPointLayerInfo);
	BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
	RenderingHints renderingHints = new Hints();
	renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	Graphics2D graphics2d = image.createGraphics();
	graphics2d.setRenderingHints(renderingHints);
	imageService.writeMap(graphics2d, mapInfo);
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	imageService.writeMap(baos, mapInfo);
	BufferedImage image2 = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
	Assert.assertArrayEquals(image2.getRGB(0, 0, 100, 100, null, 0, 100),image.getRGB(0, 0, 100, 100, null, 0, 100));
}
 
Example #3
Source File: ImageServiceImpl.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
private RasterizingContainer callPipeline(ClientMapInfo clientMapInfo, PipelineContext context, String pipelineKey)
		throws GeomajasException {
	DefaultMapContext mapContext = new DefaultMapContext();
	mapContext.setCoordinateReferenceSystem(geoService.getCrs2(clientMapInfo.getCrs()));
	MapRasterizingInfo mapInfo = (MapRasterizingInfo) clientMapInfo.getWidgetInfo(MapRasterizingInfo.WIDGET_KEY);
	mapContext.setAreaOfInterest(new ReferencedEnvelope(dtoConverterService.toInternal(mapInfo.getBounds()),
			mapContext.getCoordinateReferenceSystem()));
	RenderingHints renderingHints = new Hints();
	renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	RasterizingContainer response = new RasterizingContainer();
	context.put(RasterizingPipelineCode.CLIENT_MAP_INFO_KEY, clientMapInfo);
	context.put(RasterizingPipelineCode.RENDERING_HINTS, renderingHints);
	Map<Object, Object> rendererHints = new HashMap<Object, Object>();
	if (mapInfo.getDpi() > 0) {
		rendererHints.put(StreamingRenderer.DPI_KEY, mapInfo.getDpi());
	}
	context.put(RasterizingPipelineCode.RENDERER_HINTS, rendererHints);
	context.put(RasterizingPipelineCode.MAP_CONTEXT_KEY, mapContext);
	pipelineService.execute(pipelineKey, null, context, response);
	mapContext.dispose();
	return response;
}
 
Example #4
Source File: GeoWaveEmptyTransaction.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
public void add(final String fid, final SimpleFeature feature) throws IOException {
  feature.getUserData().put(Hints.USE_PROVIDED_FID, true);
  if (feature.getUserData().containsKey(Hints.PROVIDED_FID)) {
    final String providedFid = (String) feature.getUserData().get(Hints.PROVIDED_FID);
    feature.getUserData().put(Hints.PROVIDED_FID, providedFid);
  } else {
    feature.getUserData().put(Hints.PROVIDED_FID, feature.getID());
  }
  components.writeCommit(feature, this);

  components.getGTstore().getListenerManager().fireFeaturesAdded(
      components.getAdapter().getFeatureType().getTypeName(),
      Transaction.AUTO_COMMIT,
      ReferencedEnvelope.reference(feature.getBounds()),
      true);
}
 
Example #5
Source File: GeoWaveTransactionManagement.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
public void add(final String fid, final SimpleFeature feature) throws IOException {
  feature.getUserData().put(Hints.USE_PROVIDED_FID, true);
  if (feature.getUserData().containsKey(Hints.PROVIDED_FID)) {
    final String providedFid = (String) feature.getUserData().get(Hints.PROVIDED_FID);
    feature.getUserData().put(Hints.PROVIDED_FID, providedFid);
  } else {
    feature.getUserData().put(Hints.PROVIDED_FID, feature.getID());
  }
  if (addedFeatures.size() >= maxAdditionBufferSize) {
    flushAddsToStore(true);
  }
  addedFeatures.put(fid, feature);
  components.getGTstore().getListenerManager().fireFeaturesAdded(
      components.getAdapter().getFeatureType().getTypeName(),
      transaction,
      ReferencedEnvelope.reference(feature.getBounds()),
      false);
}
 
Example #6
Source File: Activator.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(final BundleContext bundleContext) throws Exception {
	Activator.context = bundleContext;
	final JAI jaiDef = JAI.getDefaultInstance();
	if (!(jaiDef.getOperationRegistry() instanceof ConcurrentOperationRegistry)) {
		jaiDef.setOperationRegistry(ConcurrentOperationRegistry.initializeRegistry());
	}
	ImageIO.scanForPlugins();
	Hints.putSystemDefault(Hints.FILTER_FACTORY, CommonFactoryFinder.getFilterFactory2(null));
	Hints.putSystemDefault(Hints.STYLE_FACTORY, CommonFactoryFinder.getStyleFactory(null));
	Hints.putSystemDefault(Hints.FEATURE_FACTORY, CommonFactoryFinder.getFeatureFactory(null));
	Hints.putSystemDefault(Hints.USE_JAI_IMAGEREAD, true);
	final Hints defHints = GeoTools.getDefaultHints();

	// Initialize GridCoverageFactory so that we don't make a lookup every time a factory is
	// needed
	Hints.putSystemDefault(Hints.GRID_COVERAGE_FACTORY, CoverageFactoryFinder.getGridCoverageFactory(defHints));
	// Forces early initialisation of operation registry of JAI.
	// It fixes initialisation problems in some third party equinox
	// applications such as OpenMOLE.

	// final String os = System.getProperty("os.name");
	// if (!os.startsWith("Mac")) {

	// }
	System.out.println("> JAI/ImageIO subsystem activated");
}
 
Example #7
Source File: GeoWaveGTRasterFormat.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public boolean accepts(final Object source, final Hints hints) {
  if (source == null) {
    return false;
  }
  if (isParamList(source)) {
    return true;
  }
  return validateURL(source);
}
 
Example #8
Source File: GeoWaveGTRasterFormat.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public AbstractGridCoverage2DReader getReader(final Object source, final Hints hints) {
  try {
    return new GeoWaveRasterReader(source, hints);
  } catch (final Exception e) {
    LOGGER.warn("Cannot create geowave raster reader", e);

    return null;
  }
}
 
Example #9
Source File: GeoMesaGeoIndexer.java    From rya with Apache License 2.0 5 votes vote down vote up
private static SimpleFeature createFeature(final SimpleFeatureType featureType, final Statement statement) throws ParseException {
    final String subject = StatementSerializer.writeSubject(statement);
    final String predicate = StatementSerializer.writePredicate(statement);
    final String object = StatementSerializer.writeObject(statement);
    final String context = StatementSerializer.writeContext(statement);

    // create the feature
    final Object[] noValues = {};

    // create the hash
    final String statementId = Md5Hash.md5Base64(StatementSerializer.writeStatement(statement));
    final SimpleFeature newFeature = SimpleFeatureBuilder.build(featureType, noValues, statementId);

    // write the statement data to the fields
    final Geometry geom = GeoParseUtils.getGeometry(statement, new GmlParser());
    if(geom == null || geom.isEmpty() || !geom.isValid()) {
        throw new ParseException("Could not create geometry for statement " + statement);
    }
    newFeature.setDefaultGeometry(geom);

    newFeature.setAttribute(SUBJECT_ATTRIBUTE, subject);
    newFeature.setAttribute(PREDICATE_ATTRIBUTE, predicate);
    newFeature.setAttribute(OBJECT_ATTRIBUTE, object);
    newFeature.setAttribute(CONTEXT_ATTRIBUTE, context);

    // preserve the ID that we created for this feature
    // (set the hint to FALSE to have GeoTools generate IDs)
    newFeature.getUserData().put(Hints.USE_PROVIDED_FID, java.lang.Boolean.TRUE);

    return newFeature;
}
 
Example #10
Source File: GeoWaveGeoIndexer.java    From rya with Apache License 2.0 5 votes vote down vote up
private static SimpleFeature createFeature(final SimpleFeatureType featureType, final Statement statement) throws ParseException {
    final String subject = StatementSerializer.writeSubject(statement);
    final String predicate = StatementSerializer.writePredicate(statement);
    final String object = StatementSerializer.writeObject(statement);
    final String context = StatementSerializer.writeContext(statement);

    // create the feature
    final Object[] noValues = {};

    // create the hash
    final String statementId = Md5Hash.md5Base64(StatementSerializer.writeStatement(statement));
    final SimpleFeature newFeature = SimpleFeatureBuilder.build(featureType, noValues, statementId);

    // write the statement data to the fields
    final Geometry geom = GeoParseUtils.getGeometry(statement, new GmlParser());
    if(geom == null || geom.isEmpty() || !geom.isValid()) {
        throw new ParseException("Could not create geometry for statement " + statement);
    }
    newFeature.setDefaultGeometry(geom);

    newFeature.setAttribute(SUBJECT_ATTRIBUTE, subject);
    newFeature.setAttribute(PREDICATE_ATTRIBUTE, predicate);
    newFeature.setAttribute(OBJECT_ATTRIBUTE, object);
    newFeature.setAttribute(CONTEXT_ATTRIBUTE, context);
    // GeoWave does not support querying based on a user generated feature ID
    // So, we create a separate ID attribute that it can query on.
    newFeature.setAttribute(GEO_ID_ATTRIBUTE, statementId);

    // preserve the ID that we created for this feature
    // (set the hint to FALSE to have GeoTools generate IDs)
    newFeature.getUserData().put(Hints.USE_PROVIDED_FID, java.lang.Boolean.TRUE);

    return newFeature;
}
 
Example #11
Source File: GeoWaveGTRasterFormat.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public GridCoverageWriter getWriter(final Object destination, final Hints hints) {
  throw new UnsupportedOperationException("This plugin does not support writing.");
}
 
Example #12
Source File: GeoWaveRasterReader.java    From geowave with Apache License 2.0 4 votes vote down vote up
public GeoWaveRasterReader(final GeoWaveRasterConfig config) throws DataSourceException {
  super(new Object(), new Hints());
  this.config = config;
  init(config);
}
 
Example #13
Source File: FeatureModelPropertyAccessorFactory.java    From geomajas-project-server with GNU Affero General Public License v3.0 4 votes vote down vote up
public PropertyAccessor createPropertyAccessor(Class type, String xpath, Class target, Hints hints) {
	return ACCESSOR;
}
 
Example #14
Source File: InternalFeaturePropertyAccessorFactory.java    From geomajas-project-server with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
public PropertyAccessor createPropertyAccessor(Class type, String xpath, Class target, Hints hints) {
	return ACCESSOR;
}
 
Example #15
Source File: NonLenientFilterFactoryImpl.java    From geomajas-project-server with GNU Affero General Public License v3.0 4 votes vote down vote up
public NonLenientFilterFactoryImpl(Hints hints) {
	super(hints);
}
 
Example #16
Source File: FilterServiceTestPropertyAccessorFactory.java    From geomajas-project-server with GNU Affero General Public License v3.0 4 votes vote down vote up
public PropertyAccessor createPropertyAccessor(Class type, String xpath, Class target, Hints hints) {
	return new FilterServicePropertyAccessor();
}
 
Example #17
Source File: GDALGeoTiffReader.java    From geowave with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new instance of a {@link DTEDReader}. I assume nothing about file extension.
 *
 * @param input Source object for which we want to build an {@link DTEDReader} .
 * @param hints Hints to be used by this reader throughout his life.
 * @throws DataSourceException
 */
public GDALGeoTiffReader(final Object input, final Hints hints) throws DataSourceException {
  super(input, hints, worldFileExt, new GeoTiffImageReaderSpi());
}