/** * Clips the passed geometry with the drawing area if the drawing area does not contain the passed geometry * completely. * * @param geom * the geometry to clip, must not be <code>null</code> and in the same CRS as the clipping area * @return the clipped geometry or the original geometry if the geometry lays completely in the drawing area. */ Geometry clipGeometry( final Geometry geom ) { return clipGeometry( geom, clippingArea ); }
Geometry transformToWorldCrsAndClip( final Geometry geom ) { final Geometry geomInWorldCrs = rendererContext.geomHelper.transform( geom ); if ( rendererContext.clipper == null ) { LOG.warn( "No clipper defined, geometry will be ignored for rendering" ); return null; } return rendererContext.clipper.clipGeometry( geomInWorldCrs ); }
@Override public void createLabel( TextStyling styling, String text, Geometry geom ) { if ( geom == null ) { LOG.debug( "Trying to render null geometry." ); } if ( text == null || text.length() == 0 ) { LOG.debug( "Trying to render null or zero length text." ); } geom = renderer.rendererContext.geomHelper.transform( geom ); geom = renderer.rendererContext.clipper.clipGeometry( geom ); Font font = textRenderer.convertFont( styling ); handleGeometryTypes( styling, text, font, geom ); }
/** * Calculates the points inside the geometry and inside the view port. First the passed geometry is clipped * by the view port. A multipolygon may result. For each of the polygon in this multipolygon one interior point * is created * * @param geom to create labels for, must not be <code>null</code> and in the same CRS as the viewPort * @return a MultiPoint with all calculated labels */ MultiPoint calculateInteriorPoints( final Geometry geom ) { if ( geom == null ) return null; Geometry clippedGeometry = clipGeometry( geom, viewPort ); List<Point> points = new ArrayList<Point>(); if ( clippedGeometry != null && clippedGeometry instanceof DefaultSurface ) { points.add( ( (DefaultSurface) clippedGeometry ).getInteriorPoint() ); } if ( clippedGeometry != null && clippedGeometry instanceof MultiPolygon ) { for ( Polygon p : ( (MultiPolygon) clippedGeometry ) ) { if ( p instanceof DefaultSurface ) { points.add( ( (DefaultSurface) p ).getInteriorPoint() ); } } } return new GeometryFactory().createMultiPoint( null, geom.getCoordinateSystem(), points ); }