Java 类com.vividsolutions.jts.geom.impl.PackedCoordinateSequence 实例源码

项目:fpm    文件:BoundariesA0ShapefileTest.java   
@BeforeClass
public static void setup() {

    TomtomFolder tomtomFolder = mock(TomtomFolder.class);
    when(tomtomFolder.getFile("___a0.shp")).thenReturn("src/test/resources/tomtom/boundaries/a0/andorra______________a0.shp");

    CapitalProvider capitalProvider = mock(CapitalProvider.class);
    Point point = new Point(new PackedCoordinateSequence.Double(new double[]{1.52185, 42.50760}, 2), new GeometryFactory());
    Centroid capital = new Centroid(10560000718742L, "Capital Name", "123", 0, 1, 7, point);
    when(capitalProvider.get(0)).thenReturn(newArrayList(capital));

    NameProvider nameProvider = mock(NameProvider.class);
    when(nameProvider.getAlternateNames(10200000000008L)).thenReturn(of("name", "Andorra", "name:fr", "Andorre"));

    OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
    when(osmLevelGenerator.getOsmLevel("andorra", 0)).thenReturn("2");

    BoundariesA0Shapefile shapefile = new BoundariesA0Shapefile(tomtomFolder, capitalProvider, nameProvider, osmLevelGenerator);

    shapefile.serialize("target/tests/");

    pbfContent = read(new File("target/tests/a0.osm.pbf"));
}
项目:fpm    文件:BoundariesA2ShapefileTest.java   
@BeforeClass
public static void setup() {

    TomtomFolder tomtomFolder = mock(TomtomFolder.class);
    when(tomtomFolder.getFile("___a2.shp")).thenReturn("src/test/resources/tomtom/boundaries/a2/belbe2___________a2.shp");

    NameProvider nameProvider = mock(NameProvider.class);
    when(nameProvider.getAlternateNames(10560000000838L)).thenReturn(of("name", "Leuven"));

    OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
    when(osmLevelGenerator.getOsmLevel("belbe2", 2)).thenReturn("6");

    CapitalProvider capitalProvider = mock(CapitalProvider.class);
    Point point = new Point(new PackedCoordinateSequence.Double(new double[]{4.703077, 50.8756041}, 2), new GeometryFactory());
    Centroid capital = new Centroid(10560000718742L, "Capital Name", "123", 2, 1, 7, point);
    when(capitalProvider.get(2)).thenReturn(newArrayList(capital));

    BoundariesA2Shapefile shapefile = new BoundariesA2Shapefile(tomtomFolder, capitalProvider, nameProvider, osmLevelGenerator);

    shapefile.serialize("target/tests/");

    pbfContent = read(new File("target/tests/a2.osm.pbf"));
}
项目:fpm    文件:BoundariesA1ShapefileTest.java   
@BeforeClass
public static void setup() {

    TomtomFolder tomtomFolder = mock(TomtomFolder.class);
    when(tomtomFolder.getFile("___a1.shp")).thenReturn("src/test/resources/tomtom/boundaries/a1/belgium______________a1.shp");

    NameProvider nameProvider = mock(NameProvider.class);
    when(nameProvider.getAlternateNames(10560000000843L)).thenReturn(of("name", "Brussel", "name:fr", "Bruxelles"));

    OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
    when(osmLevelGenerator.getOsmLevel("belgium", 1)).thenReturn("4");

    CapitalProvider capitalProvider = mock(CapitalProvider.class);
    Point point = new Point(new PackedCoordinateSequence.Double(new double[]{4.868077, 50.4536041}, 2), new GeometryFactory());
    Centroid capital = new Centroid(10560000718742L, "Capital Name", "123", 1, 1, 7, point);
    when(capitalProvider.get(1)).thenReturn(newArrayList(capital));

    BoundariesA1Shapefile shapefile = new BoundariesA1Shapefile(tomtomFolder, capitalProvider, nameProvider, osmLevelGenerator);

    shapefile.serialize("target/tests/");

    pbfContent = read(new File("target/tests/a1.osm.pbf"));
}
项目:fpm    文件:BoundariesA7ShapefileTest.java   
@BeforeClass
public static void setup() {

    TomtomFolder tomtomFolder = mock(TomtomFolder.class);
    when(tomtomFolder.getFile("a7.shp")).thenReturn("src/test/resources/tomtom/boundaries/a7/b___a7.shp");

    NameProvider nameProvider = mock(NameProvider.class);
    when(nameProvider.getAlternateNames(10560000000808L)).thenReturn(of("name", "Brussel Hoofdstad", "name:fr", "Brussel Hoofdstad FR", "name:nl", "Brussel Hoofdstad NL"));
    when(nameProvider.getAlternateNames(10560000000823L)).thenReturn(of("name", "Halle-Vilvoorde", "name:fr", "Halle-Vilvoorde FR", "name:nl", "Halle-Vilvoorde NL"));

    OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
    when(osmLevelGenerator.getOsmLevel("b", 0)).thenReturn("2");
    when(osmLevelGenerator.getOsmLevel("b", 7)).thenReturn("7");

    CapitalProvider capitalProvider = mock(CapitalProvider.class);
    Point point = new Point(new PackedCoordinateSequence.Double(new double[]{4.307077, 50.8366041}, 2), new GeometryFactory());
    Point point2 = new Point(new PackedCoordinateSequence.Double(new double[]{4.232918, 50.737785}, 2), new GeometryFactory());
    when(capitalProvider.get(7)).thenReturn(newArrayList(
            new Centroid(10560022000808L, "Brussel Hoofdstad", "21000", 0, 1, 2, point),
            new Centroid(10560033000808L, "Halle", "23000", 7, 1, 10, point2)));

    BoundariesA7Shapefile shapefile = new BoundariesA7Shapefile(tomtomFolder, capitalProvider, nameProvider, osmLevelGenerator);

    shapefile.serialize("target/tests/");

    pbfContent = read(new File("target/tests/a7.osm.pbf"));
}
项目:incubator-rya    文件:MongoGeoIndexerIT.java   
@Test
public void testDcSearch() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));

        // test a ring outside the point
        final double[] OUT = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
    }
}
项目:incubator-rya    文件:MongoGeoIndexerIT.java   
@Test
public void testDeleteSearch() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        f.deleteStatement(convertStatement(statement));

        // test a ring that the point would be inside of if not deleted
        final double[] in = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(in, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));

        // test a ring that the point would be outside of if not deleted
        final double[] out = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(out, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));

        // test a ring for the whole world and make sure the point is gone
        // Geomesa is a little sensitive around lon 180, so we only go to 179
        final double[] world = { -180, 90, 179, 90, 179, -90, -180, -90, -180, 90 };
        final LinearRing rWorld = gf.createLinearRing(new PackedCoordinateSequence.Double(world, 2));
        final Polygon pWorld = gf.createPolygon(rWorld, new LinearRing[] {});
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pWorld, EMPTY_CONSTRAINTS)));
    }
}
项目:incubator-rya    文件:MongoGeoIndexerIT.java   
@Test
public void testDcSearchWithContext() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct context
        assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setContext(context))));

        // query with wrong context
        assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));
    }
}
项目:incubator-rya    文件:MongoGeoIndexerIT.java   
@Test
public void testDcSearchWithSubject() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct subject
        assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(subject))));

        // query with wrong subject
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(vf.createURI("foo:subj2")))));
    }
}
项目:incubator-rya    文件:MongoGeoIndexerIT.java   
@Test
public void testDcSearchWithSubjectAndContext() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct context subject
        assertEquals(Sets.newHashSet(statement),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(context).setSubject(subject))));

        // query with wrong context
        assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));

        // query with wrong subject
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(vf.createURI("foo:subj2")))));
    }
}
项目:incubator-rya    文件:MongoGeoIndexerIT.java   
@Test
public void testDcSearchWithPredicate() throws Exception {
    // test a ring around dc
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct Predicate
        assertEquals(Sets.newHashSet(statement),
                getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(predicate)))));

        // query with wrong predicate
        assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(vf.createURI("other:pred"))))));
    }
}
项目:incubator-rya    文件:MongoGeoIndexerIT.java   
public void testAntiMeridianSearch() throws Exception {
    // verify that a search works if the bounding box crosses the anti meridian
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource context = vf.createURI("foo:context");

        final Resource subjectEast = vf.createURI("foo:subj:east");
        final URI predicateEast = GeoConstants.GEO_AS_WKT;
        final Value objectEast = vf.createLiteral("Point(179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Statement statementEast = new ContextStatementImpl(subjectEast, predicateEast, objectEast, context);
        f.storeStatement(convertStatement(statementEast));

        final Resource subjectWest = vf.createURI("foo:subj:west");
        final URI predicateWest = GeoConstants.GEO_AS_WKT;
        final Value objectWest = vf.createLiteral("Point(-179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Statement statementWest = new ContextStatementImpl(subjectWest, predicateWest, objectWest, context);
        f.storeStatement(convertStatement(statementWest));

        f.flush();

        final double[] ONE = { 178.1, 1, -178, 1, -178, -1, 178.1, -1, 178.1, 1 };

        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));

        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        assertEquals(Sets.newHashSet(statementEast, statementWest), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
    }
}
项目:incubator-rya    文件:GeoWaveIndexerTest.java   
@Test
public void testDcSearch() throws Exception {
    // test a ring around dc
    try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
        f.setConf(conf);
        f.purge(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));

        // test a ring outside the point
        final double[] OUT = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
    }
}
项目:incubator-rya    文件:GeoWaveIndexerTest.java   
@Test
public void testDeleteSearch() throws Exception {
    // test a ring around dc
    try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
        f.setConf(conf);
        f.purge(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        f.deleteStatement(convertStatement(statement));

        // test a ring that the point would be inside of if not deleted
        final double[] in = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(in, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));

        // test a ring that the point would be outside of if not deleted
        final double[] out = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(out, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));

        // test a ring for the whole world and make sure the point is gone
        final double[] world = { -180, 90, 180, 90, 180, -90, -180, -90, -180, 90 };
        final LinearRing rWorld = gf.createLinearRing(new PackedCoordinateSequence.Double(world, 2));
        final Polygon pWorld = gf.createPolygon(rWorld, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pWorld, EMPTY_CONSTRAINTS)));
    }
}
项目:incubator-rya    文件:GeoWaveIndexerTest.java   
@Test
public void testDcSearchWithContext() throws Exception {
    // test a ring around dc
    try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
        f.setConf(conf);
        f.purge(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct context
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setContext(context))));

        // query with wrong context
        Assert.assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));
    }
}
项目:incubator-rya    文件:GeoWaveIndexerTest.java   
@Test
public void testDcSearchWithSubject() throws Exception {
    // test a ring around dc
    try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
        f.setConf(conf);
        f.purge(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct subject
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(subject))));

        // query with wrong subject
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(vf.createURI("foo:subj2")))));
    }
}
项目:incubator-rya    文件:GeoWaveIndexerTest.java   
@Test
public void testDcSearchWithSubjectAndContext() throws Exception {
    // test a ring around dc
    try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
        f.setConf(conf);
        f.purge(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct context subject
        Assert.assertEquals(Sets.newHashSet(statement),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(context).setSubject(subject))));

        // query with wrong context
        Assert.assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));

        // query with wrong subject
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(vf.createURI("foo:subj2")))));
    }
}
项目:incubator-rya    文件:GeoWaveIndexerTest.java   
@Test
public void testDcSearchWithPredicate() throws Exception {
    // test a ring around dc
    try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
        f.setConf(conf);
        f.purge(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct Predicate
        Assert.assertEquals(Sets.newHashSet(statement),
                getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(predicate)))));

        // query with wrong predicate
        Assert.assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(vf.createURI("other:pred"))))));
    }
}
项目:incubator-rya    文件:GeoWaveIndexerTest.java   
public void testAntiMeridianSearch() throws Exception {
    // verify that a search works if the bounding box crosses the anti meridian
    try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
        f.setConf(conf);
        f.purge(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource context = vf.createURI("foo:context");

        final Resource subjectEast = vf.createURI("foo:subj:east");
        final URI predicateEast = GeoConstants.GEO_AS_WKT;
        final Value objectEast = vf.createLiteral("Point(179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Statement statementEast = new ContextStatementImpl(subjectEast, predicateEast, objectEast, context);
        f.storeStatement(convertStatement(statementEast));

        final Resource subjectWest = vf.createURI("foo:subj:west");
        final URI predicateWest = GeoConstants.GEO_AS_WKT;
        final Value objectWest = vf.createLiteral("Point(-179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Statement statementWest = new ContextStatementImpl(subjectWest, predicateWest, objectWest, context);
        f.storeStatement(convertStatement(statementWest));

        f.flush();

        final double[] ONE = { 178.1, 1, -178, 1, -178, -1, 178.1, -1, 178.1, 1 };

        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));

        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        Assert.assertEquals(Sets.newHashSet(statementEast, statementWest), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
    }
}
项目:incubator-rya    文件:GeoIndexerTest.java   
@Test
public void testDcSearch() throws Exception {
    // test a ring around dc
    try (final GeoMesaGeoIndexer f = new GeoMesaGeoIndexer()) {
        f.setConf(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));

        // test a ring outside the point
        final double[] OUT = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
    }
}
项目:incubator-rya    文件:GeoIndexerTest.java   
@Test
public void testDeleteSearch() throws Exception {
    // test a ring around dc
    try (final GeoMesaGeoIndexer f = new GeoMesaGeoIndexer()) {
        f.setConf(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        f.deleteStatement(convertStatement(statement));

        // test a ring that the point would be inside of if not deleted
        final double[] in = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(in, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));

        // test a ring that the point would be outside of if not deleted
        final double[] out = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(out, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));

        // test a ring for the whole world and make sure the point is gone
        // Geomesa is a little sensitive around lon 180, so we only go to 179
        final double[] world = { -180, 90, 179, 90, 179, -90, -180, -90, -180, 90 };
        final LinearRing rWorld = gf.createLinearRing(new PackedCoordinateSequence.Double(world, 2));
        final Polygon pWorld = gf.createPolygon(rWorld, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pWorld, EMPTY_CONSTRAINTS)));
    }
}
项目:incubator-rya    文件:GeoIndexerTest.java   
@Test
public void testDcSearchWithContext() throws Exception {
    // test a ring around dc
    try (final GeoMesaGeoIndexer f = new GeoMesaGeoIndexer()) {
        f.setConf(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct context
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setContext(context))));

        // query with wrong context
        Assert.assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));
    }
}
项目:incubator-rya    文件:GeoIndexerTest.java   
@Test
public void testDcSearchWithSubject() throws Exception {
    // test a ring around dc
    try (final GeoMesaGeoIndexer f = new GeoMesaGeoIndexer()) {
        f.setConf(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct subject
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(subject))));

        // query with wrong subject
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(vf.createURI("foo:subj2")))));
    }
}
项目:incubator-rya    文件:GeoIndexerTest.java   
@Test
public void testDcSearchWithSubjectAndContext() throws Exception {
    // test a ring around dc
    try (final GeoMesaGeoIndexer f = new GeoMesaGeoIndexer()) {
        f.setConf(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct context subject
        Assert.assertEquals(Sets.newHashSet(statement),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(context).setSubject(subject))));

        // query with wrong context
        Assert.assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));

        // query with wrong subject
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(vf.createURI("foo:subj2")))));
    }
}
项目:incubator-rya    文件:GeoIndexerTest.java   
@Test
public void testDcSearchWithPredicate() throws Exception {
    // test a ring around dc
    try (final GeoMesaGeoIndexer f = new GeoMesaGeoIndexer()) {
        f.setConf(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        // query with correct Predicate
        Assert.assertEquals(Sets.newHashSet(statement),
                getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(predicate)))));

        // query with wrong predicate
        Assert.assertEquals(Sets.newHashSet(),
                getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(vf.createURI("other:pred"))))));
    }
}
项目:incubator-rya    文件:GeoIndexerTest.java   
public void testAntiMeridianSearch() throws Exception {
    // verify that a search works if the bounding box crosses the anti meridian
    try (final GeoMesaGeoIndexer f = new GeoMesaGeoIndexer()) {
        f.setConf(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource context = vf.createURI("foo:context");

        final Resource subjectEast = vf.createURI("foo:subj:east");
        final URI predicateEast = GeoConstants.GEO_AS_WKT;
        final Value objectEast = vf.createLiteral("Point(179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Statement statementEast = new ContextStatementImpl(subjectEast, predicateEast, objectEast, context);
        f.storeStatement(convertStatement(statementEast));

        final Resource subjectWest = vf.createURI("foo:subj:west");
        final URI predicateWest = GeoConstants.GEO_AS_WKT;
        final Value objectWest = vf.createLiteral("Point(-179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Statement statementWest = new ContextStatementImpl(subjectWest, predicateWest, objectWest, context);
        f.storeStatement(convertStatement(statementWest));

        f.flush();

        final double[] ONE = { 178.1, 1, -178, 1, -178, -1, 178.1, -1, 178.1, 1 };

        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));

        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});

        Assert.assertEquals(Sets.newHashSet(statementEast, statementWest), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
    }
}
项目:fpm    文件:BoundariesA8ShapefileTest.java   
@BeforeClass
public static void setup() {

    TomtomFolder tomtomFolder = mock(TomtomFolder.class);
    when(tomtomFolder.getFile("a8.shp")).thenReturn("src/test/resources/tomtom/boundaries/a8/Anderlecht___________a8.shp");

    NameProvider nameProvider = mock(NameProvider.class);

    when(nameProvider.getAlternateNames(10560000000250L)) //
            .thenReturn(of("name", "Anderlecht", "name:nl", "AnderlechtNL", "name:fr", "AnderlechtFR"));
    when(nameProvider.getAlternateNames(10560000000267L)) //
            .thenReturn(of("name", "Sint-Gillis", "name:nl", "Sint-GillisNL", "name:fr", "Sint-GillisFR"));
    when(nameProvider.getAlternateNames(10560000000263L)) //
            .thenReturn(of("name", "Vorst", "name:nl", "VorstNL", "name:fr", "VorstFR"));

    when(nameProvider.getAlternateCityNames(10560000718742L)) //
            .thenReturn(of("name", "Anderlecht", "name:nl", "AnderlechtCNL", "name:fr", "AnderlechtCFR"));
    when(nameProvider.getAlternateCityNames(10560000388234L)) //
            .thenReturn(of("name", "Sint-Gillis", "name:nl", "Sint-GillisCNL", "name:fr", "Sint-GillisCFR"));
    when(nameProvider.getAlternateCityNames(10560000455427L)) //
            .thenReturn(of("name", "Vorst", "name:nl", "VorstCNL", "name:fr", "VorstCFR"));

    OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
    when(osmLevelGenerator.getOsmLevel("Anderlecht", 8)).thenReturn("8");

    TownTagger townTagger = mock(TownTagger.class);
    GeometryFactory factory = mock(GeometryFactory.class);

    Point point = new Point(new PackedCoordinateSequence.Double(new double[]{4.307077, 50.8366041}, 2), factory);
    when(townTagger.get(10560000718742L)).thenReturn(new Centroid(10560000718742L, "Anderlecht", "123", 8, 1, 7, point));

    Point point2 = new Point(new PackedCoordinateSequence.Double(new double[]{4.3451859, 50.8251293}, 2), factory);
    when(townTagger.get(10560000388234L)).thenReturn(new Centroid(10560000388234L, "Sint-Gillis", "456", 8, 1, 8, point2));

    Point point3 = new Point(new PackedCoordinateSequence.Double(new double[]{4.3134424, 50.8055758}, 2), factory);
    when(townTagger.get(10560000455427L)).thenReturn(new Centroid(10560000455427L, "Vorst", null, 8, 1, 8, point3));

    BoundariesA8Shapefile shapefile = new BoundariesA8Shapefile(tomtomFolder, townTagger, nameProvider, osmLevelGenerator);

    shapefile.serialize("target/tests/");

    pbfContent = read(new File("target/tests/a8.osm.pbf"));
    assertThat(pbfContent.getRelations()).hasSize(3);
}
项目:fpm    文件:BoundariesA9ShapefileTest.java   
@BeforeClass
public static void setup() {

    TomtomFolder tomtomFolder = mock(TomtomFolder.class);
    when(tomtomFolder.getFile("a9.shp")).thenReturn("src/test/resources/tomtom/boundaries/a9/Ranst___________a9.shp");

    NameProvider nameProvider = mock(NameProvider.class);

    when(nameProvider.getAlternateNames(10560000000077L)) //
            .thenReturn(of("name", "Ranst", "name:nl", "RanstNL", "name:fr", "RanstFR"));
    when(nameProvider.getAlternateNames(10560000000078L)) //
            .thenReturn(of("name", "Broechem", "name:nl", "BroechemNL", "name:fr", "BroechemFR"));
    when(nameProvider.getAlternateNames(10560000000079L)) //
            .thenReturn(of("name", "Emblem", "name:nl", "EmblemNL", "name:fr", "EmblemFR"));
    when(nameProvider.getAlternateNames(10560000000090L)) //
            .thenReturn(of("name", "Oelegem", "name:nl", "OelegemNL", "name:fr", "OelegemFR"));

    when(nameProvider.getAlternateCityNames(10560000419571L)) //
            .thenReturn(of("name", "Ranst", "name:nl", "RanstCNL", "name:fr", "RanstCFR"));
    when(nameProvider.getAlternateCityNames(10560000309610L)) //
            .thenReturn(of("name", "Broechem", "name:nl", "BroechemCNL", "name:fr", "BroechemCFR"));
    when(nameProvider.getAlternateCityNames(10560000712819L)) //
            .thenReturn(of("name", "Emblem", "name:nl", "EmblemCNL", "name:fr", "EmblemCFR"));
    when(nameProvider.getAlternateCityNames(10560000571768L)) //
            .thenReturn(of("name", "Oelegem", "name:nl", "OelegemCNL", "name:fr", "OelegemCFR"));

    OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
    when(osmLevelGenerator.getOsmLevel("Ranst", 8)).thenReturn("8");
    when(osmLevelGenerator.getOsmLevel("Ranst", 9)).thenReturn("9");

    TownTagger townTagger = mock(TownTagger.class);
    GeometryFactory factory = new GeometryFactory();

    Point point = new Point(new PackedCoordinateSequence.Double(new double[]{4.560886, 51.190382}, 2), factory);
    when(townTagger.get(10560000419571L)).thenReturn(new Centroid(10560000419571L, "Ranst", "123", 8, 1, 7, point));

    Point point2 = new Point(new PackedCoordinateSequence.Double(new double[]{4.601984, 51.181340}, 2), factory);
    when(townTagger.get(10560000309610L)).thenReturn(new Centroid(10560000309610L, "Broechem", "456", 8, 1, 8, point2));

    Point point3 = new Point(new PackedCoordinateSequence.Double(new double[]{4.606374, 51.162370}, 2), factory);
    when(townTagger.get(10560000712819L)).thenReturn(new Centroid(10560000712819L, "Emblem", null, 8, 1, 8, point3));

    Point point4 = new Point(new PackedCoordinateSequence.Double(new double[]{4.596975, 51.210989}, 2), factory);
    when(townTagger.get(10560000571768L)).thenReturn(new Centroid(10560000571768L, "Oelegem", "1011", 8, 1, 8, point4));

    BoundariesA9Shapefile shapefile = new BoundariesA9Shapefile(tomtomFolder, townTagger, nameProvider, osmLevelGenerator);

    shapefile.serialize("target/tests/");

    pbfContent = read(new File("target/tests/a9.osm.pbf"));
    assertThat(pbfContent.getRelations()).hasSize(4);
}
项目:incubator-rya    文件:MongoGeoIndexerIT.java   
@Test
public void testPrimeMeridianSearch() throws Exception {
    try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] ONE = { 1, 1, -1, 1, -1, -1, 1, -1, 1, 1 };
        final double[] TWO = { 2, 2, -2, 2, -2, -2, 2, -2, 2, 2 };
        final double[] THREE = { 3, 3, -3, 3, -3, -3, 3, -3, 3, 3 };

        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));
        final LinearRing r2 = gf.createLinearRing(new PackedCoordinateSequence.Double(TWO, 2));
        final LinearRing r3 = gf.createLinearRing(new PackedCoordinateSequence.Double(THREE, 2));

        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        final Polygon p2 = gf.createPolygon(r2, new LinearRing[] {});
        final Polygon p3 = gf.createPolygon(r3, new LinearRing[] {});

        assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
        assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p2, EMPTY_CONSTRAINTS)));
        assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p3, EMPTY_CONSTRAINTS)));

        // Test a ring with a hole in it
        final Polygon p3m2 = gf.createPolygon(r3, new LinearRing[] { r2 });
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p3m2, EMPTY_CONSTRAINTS)));

        // test a ring outside the point
        final double[] OUT = { 3, 3, 1, 3, 1, 1, 3, 1, 3, 3 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
    }
}
项目:incubator-rya    文件:GeoTemporalTestUtils.java   
public static Polygon poly(final double[] arr) {
    final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(arr, 2));
    final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
    return p1;
}
项目:incubator-rya    文件:GeoTemporalTestUtils.java   
public static LineString line(final double x1, final double y1, final double x2, final double y2) {
    return new LineString(new PackedCoordinateSequence.Double(new double[] { x1, y1, x2, y2 }, 2), gf);
}
项目:incubator-rya    文件:GeoWaveIndexerSfTest.java   
private static LineString line(final double x1, final double y1, final double x2, final double y2) {
    return new LineString(new PackedCoordinateSequence.Double(new double[] { x1, y1, x2, y2 }, 2), gf);
}
项目:incubator-rya    文件:GeoWaveIndexerSfTest.java   
private static Polygon poly(final double[] arr) {
    final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(arr, 2));
    final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
    return p1;
}
项目:incubator-rya    文件:GeoWaveIndexerTest.java   
@Test
public void testPrimeMeridianSearch() throws Exception {
    try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
        f.setConf(conf);
        f.purge(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] ONE = { 1, 1, -1, 1, -1, -1, 1, -1, 1, 1 };
        final double[] TWO = { 2, 2, -2, 2, -2, -2, 2, -2, 2, 2 };
        final double[] THREE = { 3, 3, -3, 3, -3, -3, 3, -3, 3, 3 };

        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));
        final LinearRing r2 = gf.createLinearRing(new PackedCoordinateSequence.Double(TWO, 2));
        final LinearRing r3 = gf.createLinearRing(new PackedCoordinateSequence.Double(THREE, 2));

        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        final Polygon p2 = gf.createPolygon(r2, new LinearRing[] {});
        final Polygon p3 = gf.createPolygon(r3, new LinearRing[] {});

        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p2, EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p3, EMPTY_CONSTRAINTS)));

        // Test a ring with a hole in it
        final Polygon p3m2 = gf.createPolygon(r3, new LinearRing[] { r2 });
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p3m2, EMPTY_CONSTRAINTS)));

        // test a ring outside the point
        final double[] OUT = { 3, 3, 1, 3, 1, 1, 3, 1, 3, 3 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
    }
}
项目:incubator-rya    文件:GeoIndexerTest.java   
@Test
public void testPrimeMeridianSearch() throws Exception {
    try (final GeoMesaGeoIndexer f = new GeoMesaGeoIndexer()) {
        f.setConf(conf);

        final ValueFactory vf = new ValueFactoryImpl();
        final Resource subject = vf.createURI("foo:subj");
        final URI predicate = GeoConstants.GEO_AS_WKT;
        final Value object = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
        final Resource context = vf.createURI("foo:context");

        final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
        f.storeStatement(convertStatement(statement));
        f.flush();

        final double[] ONE = { 1, 1, -1, 1, -1, -1, 1, -1, 1, 1 };
        final double[] TWO = { 2, 2, -2, 2, -2, -2, 2, -2, 2, 2 };
        final double[] THREE = { 3, 3, -3, 3, -3, -3, 3, -3, 3, 3 };

        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));
        final LinearRing r2 = gf.createLinearRing(new PackedCoordinateSequence.Double(TWO, 2));
        final LinearRing r3 = gf.createLinearRing(new PackedCoordinateSequence.Double(THREE, 2));

        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
        final Polygon p2 = gf.createPolygon(r2, new LinearRing[] {});
        final Polygon p3 = gf.createPolygon(r3, new LinearRing[] {});

        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p2, EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p3, EMPTY_CONSTRAINTS)));

        // Test a ring with a hole in it
        final Polygon p3m2 = gf.createPolygon(r3, new LinearRing[] { r2 });
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p3m2, EMPTY_CONSTRAINTS)));

        // test a ring outside the point
        final double[] OUT = { 3, 3, 1, 3, 1, 1, 3, 1, 3, 3 };
        final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
        final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
    }
}
项目:incubator-rya    文件:GeoIndexerSfTest.java   
private static LineString line(final double x1, final double y1, final double x2, final double y2) {
    return new LineString(new PackedCoordinateSequence.Double(new double[] { x1, y1, x2, y2 }, 2), gf);
}
项目:incubator-rya    文件:GeoIndexerSfTest.java   
private static Polygon poly(final double[] arr) {
    final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(arr, 2));
    final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
    return p1;
}