@Test public void testParseSpacingAndOrigin() throws Exception { Configuration config = new Configuration(); Template template = new Template(); template.setConfiguration(config); PointGridStrategy pointGridStrategy = new PointGridStrategy(); GridParam layerData = new GridParam(); layerData.spacing = new double[]{10, 15}; layerData.origin = new double[]{5, 5}; layerData.postConstruct(); MapBounds bounds = new BBoxMapBounds(DefaultEngineeringCRS.GENERIC_2D, 10, 20, 55, 80); Dimension mapSize = new Dimension(400, 600); double rotation = 0; double dpi = 72; MapfishMapContext context = new MapfishMapContext(bounds, mapSize, rotation, dpi, true, true); FeatureSourceSupplier supplier = pointGridStrategy.createFeatureSource(template, layerData, new LabelPositionCollector()); SimpleFeatureSource featureSource = (SimpleFeatureSource) supplier.load(requestFactory, context); try (SimpleFeatureIterator features = featureSource.getFeatures().features()) { List<Coordinate> expectedPoints = Arrays.asList( new Coordinate(15, 35), new Coordinate(25, 35), new Coordinate(35, 35), new Coordinate(45, 35), new Coordinate(15, 50), new Coordinate(25, 50), new Coordinate(35, 50), new Coordinate(45, 50), new Coordinate(15, 65), new Coordinate(25, 65), new Coordinate(35, 65), new Coordinate(45, 65) ); assertEquals(expectedPoints.size(), featureSource.getFeatures().size()); while (features.hasNext()) { SimpleFeature next = features.next(); assertTrue(next.getDefaultGeometry().getClass().getName(), next.getDefaultGeometry() instanceof Point); Coordinate coord = ((Point) next.getDefaultGeometry()).getCoordinate(); assertTrue(coord + " is not one of the expected points", expectedPoints.contains(coord)); } assertEquals(expectedPoints.size(), featureSource.getFeatures().size()); } }
@Override public FeatureSourceSupplier createFeatureSource( final Template template, final GridParam layerData, final LabelPositionCollector labels) { return new FeatureSourceSupplier() { @Nonnull @Override public FeatureSource load( @Nonnull final MfClientHttpRequestFactory requestFactory, @Nonnull final MapfishMapContext mapContext) { SimpleFeatureType featureType = GridUtils.createGridFeatureType(mapContext, Point.class); SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType); final DefaultFeatureCollection features; if (layerData.numberOfLines != null) { features = createFeaturesFromNumberOfLines(mapContext, featureBuilder, layerData, labels); } else { features = createFeaturesFromSpacing(mapContext, featureBuilder, layerData, labels); } return new CollectionFeatureSource(features); } }; }
PointGridStrategy implements GridType.GridTypeStrategy { @Override public FeatureSourceSupplier createFeatureSource( final Template template, final GridParam layerData, final LabelPositionCollector labels) { return new FeatureSourceSupplier() { @Nonnull @Override public FeatureSource load( @Nonnull final MfClientHttpRequestFactory requestFactory, @Nonnull final MapfishMapContext mapContext) { SimpleFeatureType featureType = GridUtils.createGridFeatureType(mapContext, Point.class); SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType); final DefaultFeatureCollection features; if (layerData.numberOfLines != null) { features = createFeaturesFromNumberOfLines(mapContext, featureBuilder, layerData, labels); } else { features = createFeaturesFromSpacing(mapContext, featureBuilder, layerData, labels); } return new CollectionFeatureSource(features); } }; } }
PointGridStrategy implements GridType.GridTypeStrategy { @Override public FeatureSourceSupplier createFeatureSource( final Template template, final GridParam layerData, final LabelPositionCollector labels) { return new FeatureSourceSupplier() { @Nonnull @Override public FeatureSource load( @Nonnull final MfClientHttpRequestFactory requestFactory, @Nonnull final MapfishMapContext mapContext) { SimpleFeatureType featureType = GridUtils.createGridFeatureType(mapContext, Point.class); SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType); final DefaultFeatureCollection features; if (layerData.numberOfLines != null) { features = createFeaturesFromNumberOfLines(mapContext, featureBuilder, layerData, labels); } else { features = createFeaturesFromSpacing(mapContext, featureBuilder, layerData, labels); } return new CollectionFeatureSource(features); } }; }  }
PointGridStrategy implements GridType.GridTypeStrategy { @Override public FeatureSourceSupplier createFeatureSource( final Template template, final GridParam layerData, final LabelPositionCollector labels) { return new FeatureSourceSupplier() { @Nonnull @Override public FeatureSource load( @Nonnull final MfClientHttpRequestFactory requestFactory, @Nonnull final MapfishMapContext mapContext) { SimpleFeatureType featureType = GridUtils.createGridFeatureType(mapContext, Point.class); SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType); final DefaultFeatureCollection features; if (layerData.numberOfLines != null) { features = createFeaturesFromNumberOfLines(mapContext, featureBuilder, layerData, labels); } else { features = createFeaturesFromSpacing(mapContext, featureBuilder, layerData, labels); } return new CollectionFeatureSource(features); } }; }  @Override Style defaultStyle(final Template template, final GridParam layerData); @Override FeatureSourceSupplier createFeatureSource(
            final Template template,
            final GridParam layerData,
            final LabelPositionCollector labels); }
PointGridStrategy implements GridType.GridTypeStrategy { @Override public FeatureSourceSupplier createFeatureSource( final Template template, final GridParam layerData, final LabelPositionCollector labels) { return new FeatureSourceSupplier() { @Nonnull @Override public FeatureSource load( @Nonnull final MfClientHttpRequestFactory requestFactory, @Nonnull final MapfishMapContext mapContext) { SimpleFeatureType featureType = GridUtils.createGridFeatureType(mapContext, Point.class); SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType); final DefaultFeatureCollection features; if (layerData.numberOfLines != null) { features = createFeaturesFromNumberOfLines(mapContext, featureBuilder, layerData, labels); } else { features = createFeaturesFromSpacing(mapContext, featureBuilder, layerData, labels); } return new CollectionFeatureSource(features); } }; }  @Override Style defaultStyle(final Template template, final GridParam layerData); @Override FeatureSourceSupplier createFeatureSource(
            final Template template,
            final GridParam layerData,
            final LabelPositionCollector labels);  }