Package org.neo4j.gis.spatial.osm

Examples of org.neo4j.gis.spatial.osm.OSMDataset$Way


  private void checkOSMAPI(Layer layer) {
    HashMap<Long, Integer> waysFound = new HashMap<Long, Integer>();
    long mostCommon = 0;
    int mostCount = 0;
    OSMDataset osm = (OSMDataset) layer.getDataset();
    Node wayNode = osm.getAllWayNodes().iterator().next();
    Way way = osm.getWayFrom(wayNode);
    System.out.println("Got first way " + way);
    for (WayPoint n : way.getWayPoints()) {
      Way w = n.getWay();
      Long wayId = w.getNode().getId();
      if (!waysFound.containsKey(wayId)) {
        waysFound.put(wayId, 0);
      }
      waysFound.put(wayId, waysFound.get(wayId) + 1);
      if (waysFound.get(wayId) > mostCount) {
        mostCommon = wayId;
      }
    }
    assertTrue("Start way should be most found way", way.equals(osm.getWayFromId(mostCommon)));
  }
View Full Code Here


  }

  public void testAnalysis2(String osm, int years, int days) throws IOException {
    SpatialDatabaseService spatial = new SpatialDatabaseService(graphDb());
    OSMLayer layer = (OSMLayer) spatial.getLayer(osm);
    OSMDataset dataset = (OSMDataset) layer.getDataset();
    Map<String, User> userIndex = new HashMap<String, User>();
    long latestTimestamp = 0L;
    long firstTimestamp = Long.MAX_VALUE;

    for (Node cNode : dataset.getAllChangesetNodes()) {
      long timestamp = (Long) cNode.getProperty("timestamp", 0L);
      Node userNode = dataset.getUser(cNode);
      String name = (String) userNode.getProperty("name");

      User user = userIndex.get(name);
      if (user == null) {
        user = new User(userNode.getId(), name);
View Full Code Here

            List<WayNode> nodes = Lists.newArrayList();
            String nodesString = (String) feature.getAttribute("nodes");
            for (String s : nodesString.split(";")) {
                nodes.add(new WayNode(Long.parseLong(s)));
            }
            entity = new Way(entityData, nodes);
        }

        return entity;
    }
View Full Code Here

    ESNode node1 = ESNode.Builder.create().id(1).location(1, 2).build();
    ESNode node2 = ESNode.Builder.create().id(2).location(2, 3).build();
    ESNode node3 = ESNode.Builder.create().id(3).location(3, 2).build();
    index(INDEX_NAME, node1, node2, node3);

    Way way = OsmDataBuilder.buildSampleWay(1, 1, 2, 3, 1);

    // Action
    entityDao.save(way);
    refresh(INDEX_NAME);
View Full Code Here

    ESNode node2 = ESNode.Builder.create().id(2).location(2.0, 3.0).build();
    ESNode node3 = ESNode.Builder.create().id(3).location(3.0, 2.0).build();
    ESNode node4 = ESNode.Builder.create().id(4).location(4.0, 1.0).build();
    index(INDEX_NAME, node1, node2, node3, node4);

    Way way = OsmDataBuilder.buildSampleWay(1, 1, 2, 3, 4);

    // Action
    entityDao.save(way);
    refresh(INDEX_NAME);
View Full Code Here

public class ESWayUTest {

  @Test
  public void buildFromWayEntity() {
    // Setup
    Way way = mock(Way.class);
    when(way.getId()).thenReturn(1l);
    List<Tag> tags = new ArrayList<Tag>();
    tags.add(new Tag("highway", "primary"));
    when(way.getTags()).thenReturn(tags);
    List<WayNode> wayNodes = new ArrayList<WayNode>();
    wayNodes.add(new WayNode(1l));
    wayNodes.add(new WayNode(2l));
    when(way.getWayNodes()).thenReturn(wayNodes);

    ESShapeBuilder builder = new ESShapeBuilder();
    builder.addLocation(1.0, 2.0).addLocation(2.0, 3.0);

    ESWay expected = ESWay.Builder.create().id(1l)
View Full Code Here

  }

  @Test(expected = IllegalArgumentException.class)
  public void buildFromWayEntity_withIncorrectWayNodeSize() {
    // Setup
    Way way = mock(Way.class);
    when(way.getId()).thenReturn(1l);
    List<Tag> tags = new ArrayList<Tag>();
    tags.add(new Tag("highway", "primary"));
    when(way.getTags()).thenReturn(tags);
    List<WayNode> wayNodes = new ArrayList<WayNode>();
    wayNodes.add(new WayNode(1l));
    wayNodes.add(new WayNode(2l));
    when(way.getWayNodes()).thenReturn(wayNodes);

    ESShapeBuilder builder = new ESShapeBuilder();
    builder.addLocation(1.0, 2.0);

    // Action
View Full Code Here

  public static void assertWaysEquals(Collection<Way> expected, Collection<Way> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Iterator<Way> expectedWays = expected.iterator();
    Iterator<Way> actualWays = actual.iterator();
    while (expectedWays.hasNext() && actualWays.hasNext()) {
      Way expectedWay = expectedWays.next();
      Way actualWay = actualWays.next();
      assertEquals(expectedWay, actualWay);
    }
  }
View Full Code Here

    List<Tag> tags = Arrays.asList(new Tag[] { new Tag("highway", "residential") });
    CommonEntityData entityData = new CommonEntityData(id, 0, new Date(), new OsmUser(1, "nco"), 1l, tags);
    List<WayNode> wayNodes = new ArrayList<WayNode>();
    for (int i = 0; i < nodeIds.length; i++)
      wayNodes.add(new WayNode(nodeIds[i]));
    return new Way(entityData, wayNodes);
  }
View Full Code Here

  /**
   * Test writing out a normal Way element.
   */
  @Test
  public final void testProcessNormalWay() {
    Way way =
      new Way(new CommonEntityData(1234, 2, timestamp, new OsmUser(23, "someuser"), 0));
    way.getWayNodes().add(new WayNode(1235));
    way.getWayNodes().add(new WayNode(1236));
    way.getTags().add(new Tag("waykey", "wayvalue"));
   
    testWayWriter.process(way);
    try {
      testBufferedWriter.flush();
    } catch (IOException e) {
View Full Code Here

TOP

Related Classes of org.neo4j.gis.spatial.osm.OSMDataset$Way

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.