コード例 #1
0
ファイル: GeoGitTest.java プロジェクト: ryantxu/jeo-contrib
  @Test
  public void testCreate() throws Exception {
    Schema widgets =
        new SchemaBuilder("widgets")
            .field("shape", Polygon.class)
            .field("name", String.class)
            .field("cost", Double.class)
            .schema();

    GeoGitDataset data = ws.create(widgets);
    assertEquals(0, data.count(new VectorQuery()));

    GeomBuilder gb = new GeomBuilder();

    Transaction tx = data.transaction(null);
    Cursor<Feature> c = data.cursor(new VectorQuery().append().transaction(tx));

    Feature f = c.next();
    f.put("shape", gb.point(0, 0).toPoint().buffer(10));
    f.put("name", "bomb");
    f.put("cost", 1.99);
    c.write();

    f = c.next();
    f.put("shape", gb.points(0, 0, 1, 1).toLineString().buffer(1));
    f.put("name", "dynamite");
    f.put("cost", 2.99);
    c.write();

    f = c.next();
    f.put("shape", gb.points(-5, 5, 5, 5, 2, -2, 3, -5, -3, -5, -2, -2, -5, 5).ring().toPolygon());
    f.put("name", "anvil");
    f.put("cost", 3.99);

    c.write();
    tx.commit();

    data = ws.get("widgets");
    assertEquals(3, data.count(new VectorQuery()));

    c = data.cursor(new VectorQuery().filter("name = 'bomb'"));
    assertTrue(c.hasNext());
    assertEquals(1.99, c.next().get("cost"));
  }
コード例 #2
0
ファイル: GeoGitTest.java プロジェクト: ryantxu/jeo-contrib
  void doAddPoints() throws Exception {
    GeoGitDataset points = ws.get("point");

    Transaction tx = points.transaction(null);
    Cursor<Feature> c = points.cursor(new VectorQuery().append().transaction(tx));

    Feature f = c.next();
    f.put("geometry", new GeomBuilder().point(-114, 51).toPoint());
    f.put("name", "Calgary");
    f.put("pop", 1214839l);
    c.write();

    f = c.next();
    f.put("geometry", new GeomBuilder().point(-123, 49).toPoint());
    f.put("name", "Vancouver");
    f.put("pop", 2313328l);
    c.write();

    tx.commit();
  }