Java Code Examples for org.geotools.referencing.crs.DefaultGeographicCRS

The following examples show how to use org.geotools.referencing.crs.DefaultGeographicCRS. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: sldeditor   Source File: RenderPanelImpl.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Calculate bounds.
 *
 * @return the referenced envelope
 */
private ReferencedEnvelope calculateBounds() {
    ReferencedEnvelope bounds = null;

    try {
        bounds = featureList.getBounds();

        if (bounds == null) {
            // It could be that the above call was too costly!
            bounds = featureList.getFeatures().getBounds();
        }

        if (bounds.getCoordinateReferenceSystem() == null) {
            // We need a coordinate reference system set otherwise
            // transformations fail to render
            bounds = ReferencedEnvelope.create(bounds, DefaultGeographicCRS.WGS84);
        }

        if (bounds != null) {
            expandEnvelope(bounds);
        }
    } catch (IOException e) {
        ConsoleManager.getInstance().exception(this, e);
    }
    return bounds;
}
 
Example 2
Source Project: geowave   Source File: GeometryUtils.java    License: Apache License 2.0 6 votes vote down vote up
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings()
public static CoordinateReferenceSystem getDefaultCRS() {
  if (defaultCrsSingleton == null) { // avoid sync penalty if we can
    synchronized (MUTEX_DEFAULT_CRS) {
      // have to do this inside the sync to avoid double init
      if (defaultCrsSingleton == null) {
        try {
          initClassLoader();
          defaultCrsSingleton = CRS.decode(DEFAULT_CRS_STR, true);
        } catch (final Exception e) {
          LOGGER.error("Unable to decode " + DEFAULT_CRS_STR + " CRS", e);
          defaultCrsSingleton = DefaultGeographicCRS.WGS84;
        }
      }
    }
  }
  return defaultCrsSingleton;
}
 
Example 3
Source Project: snap-desktop   Source File: FeatureLayer.java    License: GNU General Public License v3.0 6 votes vote down vote up
public FeatureLayer(LayerType layerType, final FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
                    PropertySet configuration) {
    super(layerType, configuration);
    crs = fc.getSchema().getGeometryDescriptor().getCoordinateReferenceSystem();
    if (crs == null) {
        // todo - check me! Why can this happen??? (nf)
        crs = DefaultGeographicCRS.WGS84;
    }
    final ReferencedEnvelope envelope = new ReferencedEnvelope(fc.getBounds(), crs);
    modelBounds = new Rectangle2D.Double(envelope.getMinX(), envelope.getMinY(),
                                         envelope.getWidth(), envelope.getHeight());
    mapContext = new DefaultMapContext(crs);
    final Style style = (Style) configuration.getValue(FeatureLayerType.PROPERTY_NAME_SLD_STYLE);
    mapContext.addLayer(fc, style);
    renderer = new StreamingRenderer();
    workaroundLabelCacheBug();
    style.accept(new RetrievingStyleVisitor());
    renderer.setContext(mapContext);

}
 
Example 4
Source Project: elasticgeo   Source File: GeoHashGridTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testGeoHashGrid_scaled() throws Exception {
    features = TestUtil.createAggregationFeatures(ImmutableList.of(
            ImmutableMap.of("_aggregation", mapper.writeValueAsBytes(ImmutableMap.of("key",GeoHash.encodeHash(new LatLong(-89.9,-179.9),1),"doc_count",20))),
            ImmutableMap.of("_aggregation", mapper.writeValueAsBytes(ImmutableMap.of("key",GeoHash.encodeHash(new LatLong(89.9,179.9),1),"doc_count",30)))
            ));
    ReferencedEnvelope envelope = new ReferencedEnvelope(-180,180,-90,90,DefaultGeographicCRS.WGS84);
    geohashGrid.setScale(new RasterScale(5f, 10f));
    geohashGrid.initalize(envelope, features);
    assertEquals(GeoHash.widthDegrees(1), geohashGrid.getCellWidth(), 1e-10);
    assertEquals(GeoHash.heightDegrees(1), geohashGrid.getCellHeight(), 1e-10);
    assertEquals(new Envelope(-180+GeoHash.widthDegrees(1)/2.,180-GeoHash.widthDegrees(1)/2.,-90+GeoHash.heightDegrees(1)/2.,90-GeoHash.heightDegrees(1)/2.), geohashGrid.getEnvelope());
    int ny = (int) Math.round(180/geohashGrid.getCellHeight());
    int nx = (int) Math.round(360/GeoHash.widthDegrees(1));
    assertEquals(ny, geohashGrid.getGrid().length);
    assertEquals(nx, geohashGrid.getGrid()[0].length);
    float[][] expected = new float[ny][nx];
    expected[0][7] = 10;
    expected[ny-1][0] = 5;
    IntStream.range(0, ny).forEach(i-> assertArrayEquals(geohashGrid.getGrid()[i], expected[i], 0.0f));
}
 
Example 5
Source Project: hortonmachine   Source File: MBTilesHelper.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Read the image of a tile from a generic geotools coverage reader.
 * 
 * @param reader the reader, expected to be in CRS 3857.
 * @param x the tile x.
 * @param y the tile y.
 * @param zoom the zoomlevel.
 * @return the image.
 * @throws IOException 
 */
public static BufferedImage readGridcoverageImageForTile( AbstractGridCoverage2DReader reader, int x, int y, int zoom,
        CoordinateReferenceSystem resampleCrs ) throws IOException {
    double north = tile2lat(y, zoom);
    double south = tile2lat(y + 1, zoom);
    double west = tile2lon(x, zoom);
    double east = tile2lon(x + 1, zoom);

    Coordinate ll = new Coordinate(west, south);
    Coordinate ur = new Coordinate(east, north);

    try {
        CoordinateReferenceSystem sourceCRS = DefaultGeographicCRS.WGS84;

        MathTransform transform = CRS.findMathTransform(sourceCRS, resampleCrs);
        ll = JTS.transform(ll, null, transform);
        ur = JTS.transform(ur, null, transform);
    } catch (Exception e) {
        e.printStackTrace();
    }

    BufferedImage image = ImageUtilities.imageFromReader(reader, TILESIZE, TILESIZE, ll.x, ur.x, ll.y, ur.y, resampleCrs);
    return image;
}
 
Example 6
/**
 * Creates a useless {@link GridCoverage2D} that might be usefull as placeholder.
 * 
 * @return the dummy grod coverage.
 */
public static GridCoverage2D buildDummyCoverage() {
    HashMap<String, Double> envelopeParams = new HashMap<String, Double>();
    envelopeParams.put(NORTH, 1.0);
    envelopeParams.put(SOUTH, 0.0);
    envelopeParams.put(WEST, 0.0);
    envelopeParams.put(EAST, 1.0);
    envelopeParams.put(XRES, 1.0);
    envelopeParams.put(YRES, 1.0);
    envelopeParams.put(ROWS, 1.0);
    envelopeParams.put(COLS, 1.0);
    double[][] dataMatrix = new double[1][1];
    dataMatrix[0][0] = 0;
    WritableRaster writableRaster = createWritableRasterFromMatrix(dataMatrix, true);
    return buildCoverage("dummy", writableRaster, envelopeParams, DefaultGeographicCRS.WGS84); //$NON-NLS-1$
}
 
Example 7
public static SimpleFeatureBuilder getNmeaFeatureBuilder() {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("nmea");
    b.setCRS(DefaultGeographicCRS.WGS84);
    b.add("the_geom", Point.class);
    b.add(NmeaGpsPoint.strSpeed, Double.class);
    b.add(NmeaGpsPoint.strAltitude, Double.class);
    b.add(NmeaGpsPoint.strQuality, Double.class);
    b.add(NmeaGpsPoint.strSat, Integer.class);
    b.add(NmeaGpsPoint.strHdop, Double.class);
    b.add(NmeaGpsPoint.strMsl, Double.class);
    b.add(NmeaGpsPoint.strUtctime, String.class);
    b.add(NmeaGpsPoint.strMag_var, Double.class);
    b.add(NmeaGpsPoint.strAngle, Double.class);
    final SimpleFeatureType featureType = b.buildFeatureType();
    SimpleFeatureBuilder nmeaSimpleFeatureBuilder = new SimpleFeatureBuilder(featureType);
    return nmeaSimpleFeatureBuilder;
}
 
Example 8
Source Project: hortonmachine   Source File: DaoImages.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get the current data envelope.
 * 
 * @param connection the db connection.
 * @return the envelope.
 * @throws Exception
 */
public static ReferencedEnvelope getEnvelope( IHMConnection connection ) throws Exception {
    String query = "SELECT min(" + //
            ImageTableFields.COLUMN_LON.getFieldName() + "), max(" + //
            ImageTableFields.COLUMN_LON.getFieldName() + "), min(" + //
            ImageTableFields.COLUMN_LAT.getFieldName() + "), max(" + //
            ImageTableFields.COLUMN_LAT.getFieldName() + ") " + //
            " FROM " + TABLE_IMAGES;
    try (IHMStatement statement = connection.createStatement(); IHMResultSet rs = statement.executeQuery(query);) {
        if (rs.next()) {
            double minX = rs.getDouble(1);
            double maxX = rs.getDouble(2);
            double minY = rs.getDouble(3);
            double maxY = rs.getDouble(4);

            ReferencedEnvelope env = new ReferencedEnvelope(minX, maxX, minY, maxY, DefaultGeographicCRS.WGS84);
            return env;
        }
    }

    return null;
}
 
Example 9
Source Project: hortonmachine   Source File: DaoGpsLog.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get the current data envelope.
 * 
 * @param connection the db connection.
 * @return the envelope.
 * @throws Exception
 */
public static ReferencedEnvelope getEnvelope( IHMConnection connection ) throws Exception {
    String query = "SELECT min(" + //
            GpsLogsDataTableFields.COLUMN_DATA_LON.getFieldName() + "), max(" + //
            GpsLogsDataTableFields.COLUMN_DATA_LON.getFieldName() + "), min(" + //
            GpsLogsDataTableFields.COLUMN_DATA_LAT.getFieldName() + "), max(" + //
            GpsLogsDataTableFields.COLUMN_DATA_LAT.getFieldName() + ") " + //
            " FROM " + TABLE_GPSLOG_DATA;
    try (IHMStatement statement = connection.createStatement(); IHMResultSet rs = statement.executeQuery(query);) {
        if (rs.next()) {
            double minX = rs.getDouble(1);
            double maxX = rs.getDouble(2);
            double minY = rs.getDouble(3);
            double maxY = rs.getDouble(4);

            ReferencedEnvelope env = new ReferencedEnvelope(minX, maxX, minY, maxY, DefaultGeographicCRS.WGS84);
            return env;
        }
    }

    return null;
}
 
Example 10
@Test
public void testReadTrack() throws Exception {

    CrsGeoCoding geoCoding = new CrsGeoCoding(DefaultGeographicCRS.WGS84, new Rectangle(360, 180), new AffineTransform());
    InputStreamReader reader = new InputStreamReader(getClass().getResourceAsStream("TrackData.csv"));

    FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = ImportTrackAction.readTrack(reader, geoCoding);
    assertNotNull(featureCollection);
    assertEquals(23, featureCollection.size());

    // test ordering
    SimpleFeature[] simpleFeatures = featureCollection.toArray(new SimpleFeature[0]);
    assertEquals(23, simpleFeatures.length);
    assertEquals("ID00000000", simpleFeatures[0].getID());
    assertEquals("ID00000011", simpleFeatures[11].getID());
    assertEquals("ID00000022", simpleFeatures[22].getID());
}
 
Example 11
Source Project: hortonmachine   Source File: TestENU.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void testWithGeotools() throws MatrixException {
    Coordinate c1 = new Coordinate(11, 46, 0);
    Coordinate c2 = new Coordinate(11.001, 46.001, 0);

    GeodeticCalculator gc = new GeodeticCalculator(DefaultGeographicCRS.WGS84);
    gc.setStartingGeographicPoint(c1.x, c1.y);
    gc.setDestinationGeographicPoint(c2.x, c2.y);
    double orthodromicDistance = gc.getOrthodromicDistance();

    ENU enu = new ENU(c1);
    Coordinate ce1 = enu.wgs84ToEnu(c1);
    Coordinate ce2 = enu.wgs84ToEnu(c2);

    double distance = ce1.distance(ce2);
    assertTrue(isDeltaOk(orthodromicDistance, distance));
    
    Coordinate c1Back = enu.enuToWgs84(ce1);
    Coordinate c2Back = enu.enuToWgs84(ce2);
    
    assertEquals(0, c1.distance(c1Back), 0.000001);
    assertEquals(0, c2.distance(c2Back), 0.000001);
    
}
 
Example 12
@SuppressWarnings("nls")
public void testFeatureUtils() throws Exception {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("typename");
    b.setCRS(DefaultGeographicCRS.WGS84);
    b.add("the_geom", Point.class);
    b.add("AttrName", String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Object[] values = new Object[]{GeometryUtilities.gf().createPoint(new Coordinate(0, 0)), "test"};
    builder.addAll(values);
    SimpleFeature feature = builder.buildFeature(type.getTypeName());

    Object attr = FeatureUtilities.getAttributeCaseChecked(feature, "attrname");
    assertEquals("test", attr.toString());
    attr = FeatureUtilities.getAttributeCaseChecked(feature, "attrnam");
    assertNull(attr);
}
 
Example 13
Source Project: hortonmachine   Source File: RL2NwwLayer.java    License: GNU General Public License v3.0 6 votes vote down vote up
public RL2NwwLayer( Rasterlite2Coverage rasterCoverage, Integer tileSize ) throws Exception {
    super(makeLevels(rasterCoverage, tileSize));
    this.layerName = rasterCoverage.getName();

    Envelope bounds = rasterCoverage.getBounds();
    double w = bounds.getMinX();
    double s = bounds.getMinY();
    double e = bounds.getMaxX();
    double n = bounds.getMaxY();

    double centerX = w + (e - w) / 2.0;
    double centerY = s + (n - s) / 2.0;
    Coordinate centerCoordinate = new Coordinate(centerX, centerY);

    CoordinateReferenceSystem targetCRS = DefaultGeographicCRS.WGS84;
    CoordinateReferenceSystem sourceCRS = CrsUtilities.getCrsFromSrid(rasterCoverage.getSrid());

    MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS);
    centerCoordinateLL = JTS.transform(centerCoordinate, null, transform);

    this.setUseTransparentTextures(true);

}
 
Example 14
public ImageMosaicNwwLayer( File imageMosaicShpFile, Integer tileSize, GeneralParameterValue[] gp,
        boolean removeSameColorImages ) throws Exception {
    super(makeLevels(imageMosaicShpFile, getRenderer(imageMosaicShpFile, gp), tileSize, removeSameColorImages));
    this.layerName = FileUtilities.getNameWithoutExtention(imageMosaicShpFile);

    ReferencedEnvelope envelope = OmsVectorReader.readEnvelope(imageMosaicShpFile.getAbsolutePath());
    ReferencedEnvelope envelopeLL = envelope.transform(DefaultGeographicCRS.WGS84, true);

    double w = envelopeLL.getMinX();
    double s = envelopeLL.getMinY();
    double e = envelopeLL.getMaxX();
    double n = envelopeLL.getMaxY();

    double centerX = w + (e - w) / 2.0;
    double centerY = s + (n - s) / 2.0;

    centerCoordinate = new Coordinate(centerX, centerY);

    this.setUseTransparentTextures(true);

}
 
Example 15
public RasterizedSpatialiteLasLayer( String title, ASpatialDb db, Integer tileSize, boolean transparentBackground,
        boolean doIntensity ) throws Exception {
    super(makeLevels(title, tileSize, transparentBackground, db, doIntensity));
    String plus = doIntensity ? INTENSITY : ELEVATION;
    this.layerName = title + " " + plus;
    this.setUseTransparentTextures(true);

    try {
        Envelope tableBounds = db.getTableBounds(LasSourcesTable.TABLENAME);
        GeometryColumn spatialiteGeometryColumns = db.getGeometryColumnsForTable(LasCellsTable.TABLENAME);
        CoordinateReferenceSystem dataCrs = CRS.decode("EPSG:" + spatialiteGeometryColumns.srid);
        CoordinateReferenceSystem targetCRS = DefaultGeographicCRS.WGS84;
        ReferencedEnvelope env = new ReferencedEnvelope(tableBounds, dataCrs);
        ReferencedEnvelope envLL = env.transform(targetCRS, true);

        centre = envLL.centre();
    } catch (Exception e) {
        e.printStackTrace();
        centre = CrsUtilities.WORLD.centre();
    }
}
 
Example 16
Source Project: hortonmachine   Source File: NwwPanel.java    License: GNU General Public License v3.0 6 votes vote down vote up
public ReferencedEnvelope getViewportBounds() {
    View view = wwd.getView();
    Position posUL = view.computePositionFromScreenPoint(0, 0);
    Position posLR = view.computePositionFromScreenPoint(getWidth(), getHeight());

    if (posLR != null && posUL != null) {
        double west = posUL.longitude.degrees;
        double north = posUL.latitude.degrees;
        double east = posLR.longitude.degrees;
        double south = posLR.latitude.degrees;

        ReferencedEnvelope env = new ReferencedEnvelope(west, east, south, north, DefaultGeographicCRS.WGS84);
        return env;
    } else {
        return null;// new ReferencedEnvelope(-180, 180, -90, 90,
                    // DefaultGeographicCRS.WGS84);
    }
}
 
Example 17
@Test
public void testWritingShapeFile_Geometry() throws Exception {
    SimpleFeatureType sft = createPlainFeatureType("Polygon", Geometry.class, DefaultGeographicCRS.WGS84);

    GeometryFactory gf = new GeometryFactory();
    Polygon polygon = gf.createPolygon(gf.createLinearRing(new Coordinate[]{
            new Coordinate(0, 0),
            new Coordinate(1, 0),
            new Coordinate(0, 1),
            new Coordinate(0, 0),
    }), null);
    SimpleFeature polygonFeature = createPlainFeature(sft, "_1", polygon, "");


    ArrayList<SimpleFeature> features = new ArrayList<>();
    features.add(polygonFeature);
    Class<Polygon> geomType = Polygon.class;
    doExportImport(features, geomType);
}
 
Example 18
@Test
public void testMixedGeometries_2() {

    SimpleFeatureType sft = createPlainFeatureType("Geometry", Geometry.class, DefaultGeographicCRS.WGS84);

    Geometry geometry;
    SimpleFeature feature;
    SimpleFeatureShapeFigure figure;

    geometry = createPoint();
    feature = createPlainFeature(sft, "_4", geometry, "");
    figure = new SimpleFeatureShapeFigure(feature, sceneTransformProvider, new DefaultFigureStyle());
    Assert.assertEquals(geometry, figure.getGeometry());
    Assert.assertNotNull(figure.getShape());
    Assert.assertEquals(Figure.Rank.POINT, figure.getRank());

    geometry = createGeometryCollection();
    feature = createPlainFeature(sft, "_5", geometry, "");
    figure = new SimpleFeatureShapeFigure(feature, sceneTransformProvider, new DefaultFigureStyle());
    Assert.assertEquals(geometry, figure.getGeometry());
    Assert.assertNotNull(figure.getShape());
    Assert.assertEquals(Figure.Rank.NOT_SPECIFIED, figure.getRank());
}
 
Example 19
private static SimpleFeatureType createTrackFeatureType(GeoCoding geoCoding) {
    SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder();
    ftb.setName("org.esa.snap.TrackPoint");
    /*0*/
    ftb.add("pixelPos", Point.class, geoCoding.getImageCRS());
    /*1*/
    ftb.add("geoPos", Point.class, DefaultGeographicCRS.WGS84);
    /*2*/
    ftb.add("data", Double.class);
    ftb.setDefaultGeometry(geoCoding instanceof CrsGeoCoding ? "geoPos" : "pixelPos");
    // GeoTools Bug: this doesn't work
    // ftb.userData("trackPoints", "true");
    final SimpleFeatureType ft = ftb.buildFeatureType();
    ft.getUserData().put("trackPoints", "true");
    return ft;
}
 
Example 20
@Override
public CoordinateReferenceSystem getFeatureCrs(final Product product) {
    if (product.getSceneCRS() == Product.DEFAULT_IMAGE_CRS) {
        return Product.DEFAULT_IMAGE_CRS;
    }

    final CoordinateReferenceSystem[] featureCrsBuffer = new CoordinateReferenceSystem[1];
    Runnable runnable = () -> featureCrsBuffer[0] = promptForFeatureCrs(product);
    if (!SwingUtilities.isEventDispatchThread()) {
        try {
            SwingUtilities.invokeAndWait(runnable);
        } catch (InterruptedException | InvocationTargetException e) {
            throw new RuntimeException(e);
        }
    } else {
        runnable.run();
    }
    CoordinateReferenceSystem featureCrs = featureCrsBuffer[0];
    return featureCrs != null ? featureCrs : DefaultGeographicCRS.WGS84;
}
 
Example 21
Source Project: sldeditor   Source File: TestFilterPanelv2.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBBox() {
    TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null);
    testPanel.configure("test", String.class, false);

    ReferencedEnvelope bbox =
            new ReferencedEnvelope(-1.0, 1.0, -1.9, 1.0, DefaultGeographicCRS.WGS84);
    Filter filter = ff2.bbox(ff.property("the_geom"), bbox);
    String expected = filter.toString();
    testPanel.filterDialog(String.class, filter);

    String actual = testPanel.getFilterString();

    assertEquals(expected, actual);
}
 
Example 22
Source Project: sldeditor   Source File: TestFilterPanelv2.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testContains() {
    TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null);
    testPanel.configure("test", String.class, false);

    ReferencedEnvelope bbox =
            new ReferencedEnvelope(-1.0, 1.0, -1.9, 1.0, DefaultGeographicCRS.WGS84);
    Filter filter = ff2.contains(ff.property("the_geom"), ff.literal(bbox));
    String expected = filter.toString();
    testPanel.filterDialog(String.class, filter);

    String actual = testPanel.getFilterString();

    assertEquals(expected, actual);
}
 
Example 23
Source Project: sldeditor   Source File: TestFilterPanelv2.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testIntersects() {
    TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null);
    testPanel.configure("test", String.class, false);

    ReferencedEnvelope bbox =
            new ReferencedEnvelope(-1.0, 1.0, -1.9, 1.0, DefaultGeographicCRS.WGS84);
    Filter filter = ff2.intersects(ff.property("the_geom"), ff.literal(bbox));
    String expected = filter.toString();
    testPanel.filterDialog(String.class, filter);

    String actual = testPanel.getFilterString();

    assertEquals(expected, actual);
}
 
Example 24
Source Project: sldeditor   Source File: TestFilterPanelv2.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testCrosses() {
    TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null);
    testPanel.configure("test", String.class, false);

    ReferencedEnvelope bbox =
            new ReferencedEnvelope(-1.0, 1.0, -1.9, 1.0, DefaultGeographicCRS.WGS84);
    Filter filter = ff2.crosses(ff.property("the_geom"), ff.literal(bbox));
    String expected = filter.toString();
    testPanel.filterDialog(String.class, filter);

    String actual = testPanel.getFilterString();

    assertEquals(expected, actual);
}
 
Example 25
Source Project: sldeditor   Source File: TestFilterPanelv2.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testDisjoint() {
    TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null);
    testPanel.configure("test", String.class, false);

    ReferencedEnvelope bbox =
            new ReferencedEnvelope(-1.0, 1.0, -1.9, 1.0, DefaultGeographicCRS.WGS84);
    Filter filter = ff2.disjoint(ff.property("the_geom"), ff.literal(bbox));
    String expected = filter.toString();
    testPanel.filterDialog(String.class, filter);

    String actual = testPanel.getFilterString();

    assertEquals(expected, actual);
}
 
Example 26
Source Project: sldeditor   Source File: TestFilterPanelv2.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testDWithin() {
    TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null);
    testPanel.configure("test", String.class, false);

    ReferencedEnvelope bbox =
            new ReferencedEnvelope(-1.0, 1.0, -1.9, 1.0, DefaultGeographicCRS.WGS84);
    Filter filter = ff2.dwithin(ff.property("the_geom"), ff.literal(bbox), 10.0, "km");
    String expected = filter.toString();
    testPanel.filterDialog(String.class, filter);

    String actual = testPanel.getFilterString();

    assertEquals(expected, actual);
}
 
Example 27
Source Project: sldeditor   Source File: TestFilterPanelv2.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBeyond() {
    TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null);
    testPanel.configure("test", String.class, false);

    ReferencedEnvelope bbox =
            new ReferencedEnvelope(-1.0, 1.0, -1.9, 1.0, DefaultGeographicCRS.WGS84);
    Filter filter = ff2.beyond(ff.property("the_geom"), ff.literal(bbox), 10.0, "km");
    String expected = filter.toString();
    testPanel.filterDialog(String.class, filter);

    String actual = testPanel.getFilterString();

    assertEquals(expected, actual);
}
 
Example 28
Source Project: sldeditor   Source File: TestFilterPanelv2.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testEquals() {
    TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null);
    testPanel.configure("test", String.class, false);

    ReferencedEnvelope bbox =
            new ReferencedEnvelope(-1.0, 1.0, -1.9, 1.0, DefaultGeographicCRS.WGS84);
    Filter filter = ff2.equals(ff.property("the_geom"), ff.literal(bbox));
    String expected = filter.toString();
    testPanel.filterDialog(String.class, filter);

    String actual = testPanel.getFilterString();

    assertEquals(expected, actual);
}
 
Example 29
Source Project: sldeditor   Source File: TestFilterPanelv2.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testTouches() {
    TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null);
    testPanel.configure("test", String.class, false);

    ReferencedEnvelope bbox =
            new ReferencedEnvelope(-1.0, 1.0, -1.9, 1.0, DefaultGeographicCRS.WGS84);
    Filter filter = ff2.touches(ff.property("the_geom"), ff.literal(bbox));
    String expected = filter.toString();
    testPanel.filterDialog(String.class, filter);

    String actual = testPanel.getFilterString();

    assertEquals(expected, actual);
}
 
Example 30
Source Project: sldeditor   Source File: TestFilterPanelv2.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testWithin() {
    TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null);
    testPanel.configure("test", String.class, false);

    ReferencedEnvelope bbox =
            new ReferencedEnvelope(-1.0, 1.0, -1.9, 1.0, DefaultGeographicCRS.WGS84);
    Filter filter = ff2.within(ff.property("the_geom"), ff.literal(bbox));
    String expected = filter.toString();
    testPanel.filterDialog(String.class, filter);

    String actual = testPanel.getFilterString();

    assertEquals(expected, actual);
}