Package org.neo4j.gis.spatial.osm

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


     
      processedWays = new ArrayList<Way>(INSERT_BULK_ROW_COUNT_WAY);
     
      prmIndex = 1;
      for (int i = 0; i < INSERT_BULK_ROW_COUNT_WAY; i++) {
        Way way;
        List<Geometry> geometries;
       
        way = wayBuffer.remove(0);
        processedWays.add(way);
       
        geometries = new ArrayList<Geometry>();
        if (enableBboxBuilder) {
          geometries.add(wayGeometryBuilder.createWayBbox(way));
        }
        if (enableLinestringBuilder) {
          geometries.add(wayGeometryBuilder.createWayLinestring(way));
        }
        prmIndex = wayBuilder.populateEntityParameters(bulkWayStatement, prmIndex, way, geometries);
      }
     
      try {
        bulkWayStatement.executeUpdate();
      } catch (SQLException e) {
        throw new OsmosisRuntimeException("Unable to bulk insert ways into the database.", e);
      }
     
      for (Way way : processedWays) {
        addWayTags(way);
        addWayNodes(way);
      }
    }
   
    if (complete) {
      while (wayBuffer.size() > 0) {
        Way way;
        List<Geometry> geometries;
       
        way = wayBuffer.remove(0);
       
        geometries = new ArrayList<Geometry>();
View Full Code Here


    rawUserName = attributes.getValue(ATTRIBUTE_NAME_USER);
    changesetId = buildChangesetId(attributes.getValue(ATTRIBUTE_NAME_CHANGESET_ID));
   
    user = buildUser(rawUserId, rawUserName);
   
    way = new Way(new CommonEntityData(id, version, timestampContainer, user, changesetId));
  }
View Full Code Here

  public void badSortOrderType() throws Exception {
    ChangeSimplifier simplifier = new ChangeSimplifier();
    simplifier.setChangeSink(new NullChangeWriter());
    simplifier.initialize(new HashMap<String, Object>());
    Node node;
    Way way;
   
    way = new Way(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 2));
    simplifier.process(new ChangeContainer(new WayContainer(way), ChangeAction.Modify));

    try {
      node = new Node(new CommonEntityData(1, 2, new Date(), OsmUser.NONE, 1), 1, 1);
      simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
View Full Code Here

            long id = i.getId();

            // long id, int version, Date timestamp, OsmUser user,
            // long changesetId, Collection<Tag> tags,
            // List<WayNode> wayNodes
            Way tmp;
            if (i.hasInfo()) {
                Osmformat.Info info = i.getInfo();
                tmp = new Way(new CommonEntityData(id, info.getVersion(), getDate(info),
                        getUser(info), info.getChangeset(), tags), nodes);
            } else {
                tmp = new Way(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE, NOCHANGESET,
                        tags), nodes);
            }
            sink.process(new WayContainer(tmp));
        }
    }
View Full Code Here

 
  /**
   * {@inheritDoc}
   */
  public void process(WayContainer wayContainer) {
    Way way;
    int sequenceId;
   
    way = wayContainer.getEntity();
   
    // Ignore ways with a single node because they can't be loaded into postgis.
    if (way.getWayNodes().size() > 1) {
      wayWriter.writeField(way.getId());
      wayWriter.writeField(way.getVersion());
      wayWriter.writeField(way.getUser().getId());
      wayWriter.writeField(way.getTimestamp());
      wayWriter.writeField(way.getChangesetId());
      if (enableBboxBuilder) {
        wayWriter.writeField(wayGeometryBuilder.createWayBbox(way));
      }
      if (enableLinestringBuilder) {
        wayWriter.writeField(wayGeometryBuilder.createWayLinestring(way));
      }
      wayWriter.endRecord();
     
      for (Tag tag : way.getTags()) {
        wayTagWriter.writeField(way.getId());
        wayTagWriter.writeField(tag.getKey());
        wayTagWriter.writeField(tag.getValue());
        wayTagWriter.endRecord();
      }
     
      sequenceId = 0;
      for (WayNode wayNode : way.getWayNodes()) {
        wayNodeWriter.writeField(way.getId());
        wayNodeWriter.writeField(wayNode.getNodeId());
        wayNodeWriter.writeField(sequenceId++);
        wayNodeWriter.endRecord();
      }
    }
View Full Code Here

            processedWays = new ArrayList<Way>(INSERT_BULK_ROW_COUNT_WAY);

            prmIndex = 1;
            for (int i = 0; i < INSERT_BULK_ROW_COUNT_WAY; i++) {
                Way way;

                way = wayBuffer.remove(0);
                processedWays.add(way);

                populateWayParameters(bulkWayStatement, prmIndex, way);
                prmIndex += INSERT_PRM_COUNT_WAY;
            }

            try {
                bulkWayStatement.executeUpdate();
            } catch (SQLException e) {
                throw new OsmosisRuntimeException("Unable to bulk insert ways into the database.", e);
            }

            for (Way way : processedWays) {
                addWayTags(way);
                addWayNodes(way);
            }
        }

        if (complete) {
            while (wayBuffer.size() > 0) {
                Way way;

                way = wayBuffer.remove(0);

                populateWayParameters(singleWayStatement, 1, way);
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void process(WayContainer wayContainer) {
        Way way;
        long wayId;

        flushNodes(true);

        way = wayContainer.getEntity();
        wayId = way.getId();

        if (wayId >= maxWayId) {
            maxWayId = wayId + 1;
        }
        if (wayId < minWayId) {
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public Way parseRecord(ResultSet resultSet) {
    try {
      return new Way(
        new CommonEntityData(
          resultSet.getLong("id"),
          resultSet.getInt("version"),
          new Date(resultSet.getTimestamp("tstamp").getTime()),
          buildUser(resultSet),
View Full Code Here

 
  /**
   * {@inheritDoc}
   */
  public void process(WayContainer wayContainer) {
    Way way;
    long wayId;
    long objectOffset;
    int minimumTile;
    int maximumTile;
    boolean tilesFound;
   
    if (nodeObjectReader == null) {
      nodeObjectStore.complete();
      nodeObjectReader = nodeObjectStore.createReader();
    }
    if (nodeObjectOffsetIndexReader == null) {
      nodeObjectOffsetIndexWriter.complete();
      nodeObjectOffsetIndexReader = nodeObjectOffsetIndexWriter.createReader();
    }
   
    way = wayContainer.getEntity();
    wayId = way.getId();
   
    // Write the way to the object store and save the file offset in an
    // index keyed by way id.
    objectOffset = wayObjectStore.add(way);
    wayObjectOffsetIndexWriter.write(
      new LongLongIndexElement(wayId, objectOffset)
    );
   
    if (enableWayTileIndex) {
    // Calculate the minimum and maximum tile indexes for the way.
    tilesFound = false;
    minimumTile = 0;
    maximumTile = 0;
    for (WayNode wayNode : way.getWayNodes()) {
      long nodeId;
      Node node;
      int tile;
     
      nodeId = wayNode.getNodeId();
     
      try {
      node = nodeObjectReader.get(
        nodeObjectOffsetIndexReader.get(nodeId).getValue()
      );
     
      tile = (int) tileCalculator.calculateTile(node.getLatitude(), node.getLongitude());
     
      if (tilesFound) {
        if (uintComparator.compare(tile, minimumTile) < 0) {
          minimumTile = tile;
        }
        if (uintComparator.compare(maximumTile, tile) < 0) {
          maximumTile = tile;
        }
       
      } else {
        minimumTile = tile;
        maximumTile = tile;
       
        tilesFound = true;
      }
       
      } catch (NoSuchIndexElementException e) {
        // Ignore any referential integrity problems.
        if (LOG.isLoggable(Level.FINER)) {
          LOG.finest(
            "Ignoring referential integrity problem where way " + wayId
            + " refers to non-existent node " + nodeId + "."
          );
    }
      }
    }
   
    // Write the way id to an index keyed by tile but only if tiles were
    // actually found.
    if (tilesFound) {
    wayTileIndexWriter.write(wayId, minimumTile, maximumTile);
      }
     
    } else {
      for (WayNode wayNode : way.getWayNodes()) {
        long nodeId;
       
        nodeId = wayNode.getNodeId();
       
        nodeWayIndexWriter.write(new LongLongIndexElement(nodeId, wayId));
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public Way getEntity(long entityId) {
    Way entity;
   
    entity = super.getEntity(entityId);
   
    loadFeatures(entityId, entity);
   
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.