Commit 3ab7cbd6 authored by DBlasby's avatar DBlasby Committed by Torben Barsbsballe
Browse files

improvments

parent b70db194
......@@ -29,7 +29,7 @@ import com.google.common.base.Throwables;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier;
import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
class PipelineBuilder {
......@@ -69,14 +69,14 @@ class PipelineBuilder {
}
public static PipelineBuilder newBuilder(ReferencedEnvelope renderingArea, Rectangle paintArea,
CoordinateReferenceSystem sourceCrs) throws FactoryException {
CoordinateReferenceSystem sourceCrs, double overSampleFactor) throws FactoryException {
Context context = createContext(renderingArea, paintArea, sourceCrs);
Context context = createContext(renderingArea, paintArea, sourceCrs, overSampleFactor);
return new PipelineBuilder(context);
}
private static Context createContext(ReferencedEnvelope mapArea, Rectangle paintArea,
CoordinateReferenceSystem sourceCrs) throws FactoryException {
CoordinateReferenceSystem sourceCrs, double overSampleFactor) throws FactoryException {
Context context = new Context();
context.renderingArea = mapArea;
......@@ -100,10 +100,10 @@ class PipelineBuilder {
} catch (TransformException e) {
throw Throwables.propagate(e);
}
context.screenSimplificationDistance = 0.25;
context.sourceCRSSimplificationDistance = Math.min(spans[0], spans[1]);
context.screenSimplificationDistance = 0.25/overSampleFactor;
context.sourceCRSSimplificationDistance = Math.min(spans[0], spans[1])/overSampleFactor;
context.screenMap = new ScreenMap(0, 0, paintArea.width, paintArea.height);
context.screenMap.setSpans(spans[0], spans[1]);
context.screenMap.setSpans(spans[0]/overSampleFactor, spans[1]/overSampleFactor);
context.screenMap.setTransform(context.sourceToScreen);
return context;
......@@ -257,10 +257,10 @@ class PipelineBuilder {
if (geom.getDimension() == 0) {
return geom;
}
DouglasPeuckerSimplifier simplifier = new DouglasPeuckerSimplifier(geom);
//DJB: Use this instead of com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier because
// DPS does NOT do a good job with polygons.
TopologyPreservingSimplifier simplifier = new TopologyPreservingSimplifier(geom);
simplifier.setDistanceTolerance(this.distanceTolerance);
simplifier.setEnsureValid(true);
Geometry simplified = simplifier.getResultGeometry();
return simplified;
}
......
......@@ -52,6 +52,7 @@ public class VectorTileMapOutputFormat extends AbstractMapOutputFormat {
private final VectorTileBuilderFactory tileBuilderFactory;
private boolean clipToMapBounds;
private double overSamplingFactor = 2.0; //1=no oversampling, 4=four time oversample (generialization will be 1/4 pixel)
private boolean transformToScreenCoordinates;
......@@ -61,6 +62,10 @@ public class VectorTileMapOutputFormat extends AbstractMapOutputFormat {
this.tileBuilderFactory = tileBuilderFactory;
}
public void setOverSamplingFactor(double factor) {
this.overSamplingFactor = factor;
}
public void setClipToMapBounds(boolean clip) {
this.clipToMapBounds = clip;
}
......@@ -100,17 +105,17 @@ public class VectorTileMapOutputFormat extends AbstractMapOutputFormat {
PipelineBuilder builder;
try {
builder = PipelineBuilder.newBuilder(renderingArea, paintArea, sourceCrs);
builder = PipelineBuilder.newBuilder(renderingArea, paintArea, sourceCrs,overSamplingFactor);
} catch (FactoryException e) {
throw new ServiceException(e);
}
Pipeline pipeline = builder//
.preprocess()//
.transform(transformToScreenCoordinates)//
.simplify(transformToScreenCoordinates)//
.clip(clipToMapBounds, transformToScreenCoordinates)//
.collapseCollections()//
Pipeline pipeline = builder
.preprocess()
.transform(transformToScreenCoordinates)
.simplify(transformToScreenCoordinates)
.clip(clipToMapBounds, transformToScreenCoordinates)
.collapseCollections()
.build();
Query query = getStyleQuery(layer, mapContent);
......
......@@ -21,7 +21,7 @@
<bean id="wmsTopoJSONMapOutputFormat" class="org.geoserver.wms.vector.VectorTileMapOutputFormat">
<constructor-arg ref="wms"/>
<constructor-arg ref="wmsTopoJSONBuilderFactory"/>
<property name="clipToMapBounds" value="false">
<property name="clipToMapBounds" value="true">
<description>Use geometries clipped to tile bounds
Clipping is set to false since OL3 does not yet have a way to deal with clipped geometries.
It should be set to true once OL3 knows what to do with clipped geometries.
......@@ -30,6 +30,9 @@
<property name="transformToScreenCoordinates" value="true">
<description>The topoJSON map builder expects geometries in screen coordinates</description>
</property>
<property name="overSamplingFactor" value="2.0">
<description>Sub-pixel accuracy - higher value means less generalization (higher resolution results)</description>
</property>
</bean>
<bean id="wmsGeoJsonBuilderFactory" class="org.geoserver.wms.geojson.GeoJsonBuilderFactory">
......@@ -38,10 +41,13 @@
<bean id="wmsGeoJsonMapOutputFormat" class="org.geoserver.wms.vector.VectorTileMapOutputFormat">
<constructor-arg ref="wms" />
<constructor-arg ref="wmsGeoJsonBuilderFactory" />
<property name="clipToMapBounds" value="false"/>
<property name="clipToMapBounds" value="true"/>
<property name="transformToScreenCoordinates" value="false">
<description>The geoJson map builder expects geometries in map coordinates</description>
</property>
<property name="overSamplingFactor" value="2.0">
<description>Sub-pixel accuracy - higher value means less generalization (higher resolution results)</description>
</property>
</bean>
<bean id="wmsMapBoxBuilderFactory" class="org.geoserver.wms.mapbox.MapBoxTileBuilderFactory">
......@@ -52,6 +58,9 @@
<constructor-arg ref="wmsMapBoxBuilderFactory"/>
<property name="clipToMapBounds" value="true" />
<property name="transformToScreenCoordinates" value="true" />
<property name="overSamplingFactor" value="2.0">
<description>Sub-pixel accuracy - higher value means less generalization (higher resolution results)</description>
</property>
</bean>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment