// prepare hints
// ... basic one, we want fast and compact coordinate sequences and geometries optimized
// for the collection of one item case (typical in shapefiles)
LiteCoordinateSequenceFactory csFactory = new LiteCoordinateSequenceFactory();
GeometryFactory gFactory = new SimpleGeometryFactory(csFactory);
Hints hints = new Hints(Hints.JTS_COORDINATE_SEQUENCE_FACTORY, csFactory);
hints.put(Hints.JTS_GEOMETRY_FACTORY, gFactory);
hints.put(Hints.FEATURE_2D, Boolean.TRUE);
// update the screenmaps
try {
CoordinateReferenceSystem crs = getNativeCRS(schema, attributes);
if(crs != null) {
Set<RenderingHints.Key> fsHints = source.getSupportedHints();
SingleCRS crs2D = crs == null ? null : CRS.getHorizontalCRS(crs);
MathTransform mt = buildFullTransform(crs2D, mapCRS, worldToScreenTransform);
double[] spans = Decimator.computeGeneralizationDistances(mt.inverse(), screenSize, generalizationDistance);
double distance = spans[0] < spans[1] ? spans[0] : spans[1];
for (LiteFeatureTypeStyle fts : styles) {
if(fts.screenMap != null) {
fts.screenMap.setTransform(mt);
fts.screenMap.setSpans(spans[0], spans[1]);
if(fsHints.contains(Hints.SCREENMAP)) {
// replace the renderer screenmap with the hint, and avoid doing
// the work twice
hints.put(Hints.SCREENMAP, fts.screenMap);
fts.screenMap = null;
}
}
}
if(renderingTransformation) {
// the RT might need valid geometries, we can at most apply a topology
// preserving generalization
if(fsHints.contains(Hints.GEOMETRY_GENERALIZATION)) {
hints.put(Hints.GEOMETRY_GENERALIZATION, distance);
inMemoryGeneralization = false;
}
} else {
// ... if possible we let the datastore do the generalization
if(fsHints.contains(Hints.GEOMETRY_SIMPLIFICATION)) {
// good, we don't need to perform in memory generalization, the datastore
// does it all for us
hints.put(Hints.GEOMETRY_SIMPLIFICATION, distance);
inMemoryGeneralization = false;
} else if(fsHints.contains(Hints.GEOMETRY_DISTANCE)) {
// in this case the datastore can get us close, but we can still
// perform some in memory generalization
hints.put(Hints.GEOMETRY_DISTANCE, distance);
}
}
}
} catch(Exception e) {
LOGGER.log(Level.INFO, "Error computing the generalization hints", e);