use of org.apache.sis.portrayal.MapLayers in project geotoolkit by Geomatys.
the class MeridianTest method testLoopN170toP170.
/**
* Test loop around the -180 meridian.
*/
@Test
public void testLoopN170toP170() throws Exception {
final Polygon poly = GF.createPolygon(new Coordinate[] { new Coordinate(-170, +10), new Coordinate(+170, +10), new Coordinate(+170, -10), new Coordinate(-170, -10), new Coordinate(-170, +10) });
final MapLayers context = createFeatureLayer(poly, Polygon.class);
final SceneDef sceneDef = new SceneDef(context);
final GeneralEnvelope env = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
env.setRange(0, -180, +180);
env.setRange(1, -90, +90);
final CanvasDef canvasDef = new CanvasDef();
canvasDef.setEnvelope(env);
canvasDef.setDimension(new Dimension(360, 180));
canvasDef.setBackground(Color.WHITE);
final BufferedImage image = DefaultPortrayalService.portray(canvasDef, sceneDef);
checkImage(image, new Rectangle(350, 80, 10, 20), new Rectangle(0, 80, 10, 20));
}
use of org.apache.sis.portrayal.MapLayers in project geotoolkit by Geomatys.
the class MeridianTest method testEnvelopeWorld.
@Test
public void testEnvelopeWorld() throws Exception {
final GeneralEnvelope genv = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
genv.setRange(0, -180, +180);
genv.setRange(1, -90, +90);
final Geometry poly = GeometricUtilities.toJTSGeometry(genv, GeometricUtilities.WrapResolution.SPLIT);
final MapLayers context = createFeatureLayer(poly, Geometry.class);
final SceneDef sceneDef = new SceneDef(context);
final GeneralEnvelope env = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
env.setRange(0, -180, +180);
env.setRange(1, -90, +90);
final CanvasDef canvasDef = new CanvasDef(new Dimension(360, 180), env);
canvasDef.setBackground(Color.WHITE);
final BufferedImage image = DefaultPortrayalService.portray(canvasDef, sceneDef);
checkImage(image, new Rectangle(0, 0, 360, 180));
}
use of org.apache.sis.portrayal.MapLayers in project geotoolkit by Geomatys.
the class MeridianTest method createFeatureLayer.
private static <T extends Geometry> MapLayers createFeatureLayer(T geometry, Class<T> geomClass) {
final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
ftb.setName("test");
ftb.addAttribute(geomClass).setName("geom").setCRS(CommonCRS.WGS84.normalizedGeographic()).addRole(AttributeRole.DEFAULT_GEOMETRY);
final FeatureType type = ftb.build();
final Feature feature = type.newInstance();
JTS.setCRS(geometry, CommonCRS.WGS84.normalizedGeographic());
feature.setPropertyValue("geom", geometry);
final FeatureSet col = new InMemoryFeatureSet(type, Arrays.asList(feature));
final PolygonSymbolizer symbol = SF.polygonSymbolizer(SF.stroke(Color.BLACK, 0), SF.fill(Color.RED), null);
final MutableStyle style = SF.style(symbol);
final MapLayer layer = MapBuilder.createLayer(col);
layer.setStyle(style);
final MapLayers context = MapBuilder.createContext();
context.getComponents().add(layer);
return context;
}
use of org.apache.sis.portrayal.MapLayers in project geotoolkit by Geomatys.
the class MeridianTest method testFullWrapAroundGeometry.
/**
* Test a geometry which makes a full width wrap around.
* Some geometry at the poles often have a line segment which makes a complete
* world wrap.
*/
@Test
public void testFullWrapAroundGeometry() throws Exception {
final Polygon poly = GF.createPolygon(new Coordinate[] { new Coordinate(-180, +10), new Coordinate(+180, +10), new Coordinate(+180, -10), new Coordinate(-180, -10), new Coordinate(-180, +10) });
final MapLayers context = createFeatureLayer(poly, Polygon.class);
final SceneDef sceneDef = new SceneDef(context);
final GeneralEnvelope env = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
env.setRange(0, -180, +180);
env.setRange(1, -90, +90);
final CanvasDef canvasDef = new CanvasDef(new Dimension(360, 180), env);
canvasDef.setBackground(Color.WHITE);
final BufferedImage image = DefaultPortrayalService.portray(canvasDef, sceneDef);
checkImage(image, new Rectangle(0, 80, 360, 20));
}
use of org.apache.sis.portrayal.MapLayers in project geotoolkit by Geomatys.
the class MeridianTest method testImageCrossN190toN170.
/**
* Test coverage that overlaps the -180 meridian.
*/
@Test
public void testImageCrossN190toN170() throws Exception {
final GeneralEnvelope covEnv = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
covEnv.setRange(0, -190, -170);
covEnv.setRange(1, -10, +10);
final MapLayers context = createCoverageLayer(covEnv);
final SceneDef sceneDef = new SceneDef(context);
final GeneralEnvelope env = new GeneralEnvelope(CommonCRS.WGS84.normalizedGeographic());
env.setRange(0, -180, +180);
env.setRange(1, -90, +90);
final CanvasDef canvasDef = new CanvasDef(new Dimension(360, 180), env);
canvasDef.setBackground(Color.WHITE);
final BufferedImage image = DefaultPortrayalService.portray(canvasDef, sceneDef);
checkImage(image, new Rectangle(350, 80, 10, 20), new Rectangle(0, 80, 10, 20));
}
Aggregations