Skip to content
Permalink
Browse files

Writers: use longs in progress logs, fix #1137

  • Loading branch information
devemux86 committed Nov 14, 2019
1 parent 390e5f7 commit 53a73e56946e0337f7e7a8947c229a3673132672
@@ -2,7 +2,7 @@
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2015 lincomatic
* Copyright 2017-2018 Gustl22
* Copyright 2017 devemux86
* Copyright 2017-2019 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -17,49 +17,31 @@
*/
package org.mapsforge.map.writer;

import gnu.trove.iterator.TLongIterator;
import gnu.trove.list.array.TLongArrayList;
import gnu.trove.map.hash.TLongObjectHashMap;
import gnu.trove.map.hash.TShortIntHashMap;
import gnu.trove.procedure.TObjectProcedure;
import gnu.trove.set.TLongSet;
import gnu.trove.set.hash.TLongHashSet;
import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.geom.TopologyException;
import org.mapsforge.core.model.BoundingBox;
import org.mapsforge.core.util.LatLongUtils;
import org.mapsforge.core.util.MercatorProjection;
import org.mapsforge.map.writer.model.MapWriterConfiguration;
import org.mapsforge.map.writer.model.NodeResolver;
import org.mapsforge.map.writer.model.OSMTag;
import org.mapsforge.map.writer.model.TDNode;
import org.mapsforge.map.writer.model.TDRelation;
import org.mapsforge.map.writer.model.TDWay;
import org.mapsforge.map.writer.model.TileBasedDataProcessor;
import org.mapsforge.map.writer.model.TileCoordinate;
import org.mapsforge.map.writer.model.TileData;
import org.mapsforge.map.writer.model.TileGridLayout;
import org.mapsforge.map.writer.model.TileInfo;
import org.mapsforge.map.writer.model.WayResolver;
import org.mapsforge.map.writer.model.ZoomIntervalConfiguration;
import org.mapsforge.map.writer.model.*;
import org.mapsforge.map.writer.util.GeoUtils;
import org.mapsforge.map.writer.util.OSMUtils;
import org.openstreetmap.osmosis.core.domain.v0_6.Node;
import org.openstreetmap.osmosis.core.domain.v0_6.Relation;
import org.openstreetmap.osmosis.core.domain.v0_6.Way;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import gnu.trove.iterator.TLongIterator;
import gnu.trove.list.array.TLongArrayList;
import gnu.trove.map.hash.TLongObjectHashMap;
import gnu.trove.map.hash.TShortIntHashMap;
import gnu.trove.procedure.TObjectProcedure;
import gnu.trove.set.TLongSet;
import gnu.trove.set.hash.TLongHashSet;

abstract class BaseTileBasedDataProcessor implements TileBasedDataProcessor, NodeResolver, WayResolver {

protected class RelationHandler implements TObjectProcedure<TDRelation> {
@@ -69,7 +51,7 @@
private Map<Integer, List<Integer>> outerToInner;
private final WayPolygonizer polygonizer = new WayPolygonizer();

private int nRelations = 0;
private long nRelations = 0;

@Override
public boolean execute(TDRelation relation) {
@@ -265,7 +247,7 @@ private void addInnerWays(TDWay outer) {
}

protected class WayHandler implements TObjectProcedure<TDWay> {
private int nWays = 0;
private long nWays = 0;

@Override
public boolean execute(TDWay way) {
@@ -323,9 +305,9 @@ public boolean execute(TDWay way) {
protected final Map<Long, Long> partRootRelations;

// Accounting
private int amountOfNodesProcessed = 0;
private int amountOfRelationsProcessed = 0;
private int amountOfWaysProcessed = 0;
private long amountOfNodesProcessed = 0;
private long amountOfRelationsProcessed = 0;
private long amountOfWaysProcessed = 0;
protected final NumberFormat nfCounts = NumberFormat.getInstance();

protected final ZoomIntervalConfiguration zoomIntervalConfiguration;
@@ -426,17 +408,17 @@ public void addWay(Way way) {
}

@Override
public int getNodesNumber() {
public long getNodesNumber() {
return amountOfNodesProcessed;
}

@Override
public int getRelationsNumber() {
public long getRelationsNumber() {
return amountOfRelationsProcessed;
}

@Override
public int getWaysNumber() {
public long getWaysNumber() {
return amountOfWaysProcessed;
}

@@ -573,7 +555,7 @@ protected void handleImplicitWayRelations() {
return;
}

/*int progressImplicitRelations = 0;
/*long progressImplicitRelations = 0;
float limitImplicitRelations = this.tilesToPartElements.entrySet().size();*/

// Iterate through tiles which contain parts
@@ -592,7 +574,7 @@ protected void handleImplicitWayRelations() {
+ "%% - Tile (" + tilePartElementEntry.getKey().getX()
+ ", " + tilePartElementEntry.getKey().getY() + ")";
progressImplicitRelations++;
int nRootElements = 0;*/
long nRootElements = 0;*/

// Load parts only once in cache
List<TDWay> pElems = new ArrayList<>();
@@ -1,7 +1,7 @@
/*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2015 lincomatic
* Copyright 2017 devemux86
* Copyright 2017-2019 devemux86
* Copyright 2017-2018 Gustl22
*
* This program is free software: you can redistribute it and/or modify it under the
@@ -139,7 +139,7 @@ public void complete() {
// Prepare implicit way relations
// (should be done here, before handling ways, although
// the WayHandler does only process ids in HD Processor)
int nWays = 0;
long nWays = 0;
ReleasableIterator<Way> wayReader = this.wayStore.iterate();
while (wayReader.hasNext()) {
if (this.progressLogs) {
@@ -1,6 +1,6 @@
/*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2017 devemux86
* Copyright 2017-2019 devemux86
* Copyright 2018 Gustl22
*
* This program is free software: you can redistribute it and/or modify it under the
@@ -119,15 +119,15 @@
/**
* @return the number of added nodes
*/
int getNodesNumber();
long getNodesNumber();

/**
* @return the number of added relations
*/
int getRelationsNumber();
long getRelationsNumber();

/**
* @return the number of added ways
*/
int getWaysNumber();
long getWaysNumber();
}
@@ -1,5 +1,6 @@
/*
* Copyright 2017-2018 Gustl22
* Copyright 2019 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,7 +16,6 @@
package org.mapsforge.poi.writer;

import com.google.common.collect.Lists;

import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Point;
@@ -24,22 +24,12 @@
import org.mapsforge.core.model.LatLong;
import org.mapsforge.poi.storage.DbConstants;
import org.mapsforge.poi.writer.logging.LoggerWrapper;
import org.openstreetmap.osmosis.core.domain.v0_6.EntityType;
import org.openstreetmap.osmosis.core.domain.v0_6.Relation;
import org.openstreetmap.osmosis.core.domain.v0_6.RelationMember;
import org.openstreetmap.osmosis.core.domain.v0_6.Tag;
import org.openstreetmap.osmosis.core.domain.v0_6.Way;
import org.openstreetmap.osmosis.core.domain.v0_6.WayNode;
import org.openstreetmap.osmosis.core.domain.v0_6.*;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.logging.Logger;

/**
@@ -171,7 +161,7 @@ void filterBoundaries(Relation relation) {
}

void processBoundaries() {
int nPostalBounds = 0;
long nPostalBounds = 0;
for (Relation postalBoundary : postalBoundaries) {
if (writer.configuration.isProgressLogs()) {
if (++nPostalBounds % 10 == 0) {
@@ -184,7 +174,7 @@ void processBoundaries() {
commit();

for (int i = administrativeBoundaries.size() - 1; i >= 0; i--) {
int nAdminBounds = 0;
long nAdminBounds = 0;
List<Relation> administrativeBoundary = administrativeBoundaries.get(i);
for (Relation relation : administrativeBoundary) {
if (writer.configuration.isProgressLogs()) {
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 devemux86
* Copyright 2015-2019 devemux86
* Copyright 2017-2018 Gustl22
* Copyright 2019 Kamil Donoval
*
@@ -85,10 +85,10 @@ public static PoiWriter newInstance(PoiWriterConfiguration configuration, Progre
private GeoTagger geoTagger;

// Statistics
private int nNodes = 0;
private int nWays = 0;
private int nRelations = 0;
private int poiAdded = 0;
private long nNodes = 0;
private long nWays = 0;
private long nRelations = 0;
private long poiAdded = 0;

// Database
Connection conn = null;

0 comments on commit 53a73e5

Please sign in to comment.
You can’t perform that action at this time.