Update basemap gen
This commit is contained in:
parent
f42b66aeb4
commit
3fd27c2db3
3 changed files with 51 additions and 14 deletions
|
@ -66,15 +66,15 @@ public class BinaryInspector {
|
|||
// test cases show info
|
||||
if(args.length == 1 && "test".equals(args[0])) {
|
||||
in.inspector(new String[]{
|
||||
"-vpoi",
|
||||
// "-vmap", "-vmapobjects",
|
||||
// "-vpoi",
|
||||
"-vmap", "-vmapobjects",
|
||||
// "-vrouting",
|
||||
// "-vaddress", "-vcities","-vstreetgroups",
|
||||
// "-vstreets", "-vbuildings", "-vintersections",
|
||||
// "-zoom=16",
|
||||
"-zoom=14",
|
||||
// "-bbox=1.74,51.17,1.75,51.16",
|
||||
// "-vstats",
|
||||
"/Users/victorshcherb/osmand/osm-gen/Synthetic_test_rendering.obf"
|
||||
"/Users/victorshcherb/osmand/osm-gen/032.obf"
|
||||
});
|
||||
} else {
|
||||
in.inspector(args);
|
||||
|
|
|
@ -103,11 +103,18 @@ public abstract class Entity {
|
|||
private Map<String, String> tags = null;
|
||||
private final long id;
|
||||
private boolean dataLoaded;
|
||||
private int modify;
|
||||
public static final int MODIFY_UNKNOWN = 0;
|
||||
public static final int MODIFY_DELETED = -1;
|
||||
public static final int MODIFY_MODIFIED = 1;
|
||||
public static final int MODIFY_CREATED = 2;
|
||||
|
||||
public Entity(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Entity(Entity copy, long id) {
|
||||
this.id = id;
|
||||
for (String t : copy.getTagKeySet()) {
|
||||
|
@ -116,6 +123,14 @@ public abstract class Entity {
|
|||
this.dataLoaded = copy.dataLoaded;
|
||||
}
|
||||
|
||||
public int getModify() {
|
||||
return modify;
|
||||
}
|
||||
|
||||
public void setModify(int modify) {
|
||||
this.modify = modify;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -30,12 +30,16 @@ import org.xml.sax.helpers.DefaultHandler;
|
|||
public class OsmBaseStorage extends DefaultHandler {
|
||||
|
||||
protected static final String ELEM_OSM = "osm"; //$NON-NLS-1$
|
||||
protected static final String ELEM_OSMCHANGE = "osmChange"; //$NON-NLS-1$
|
||||
protected static final String ELEM_NODE = "node"; //$NON-NLS-1$
|
||||
protected static final String ELEM_TAG = "tag"; //$NON-NLS-1$
|
||||
protected static final String ELEM_WAY = "way"; //$NON-NLS-1$
|
||||
protected static final String ELEM_ND = "nd"; //$NON-NLS-1$
|
||||
protected static final String ELEM_RELATION = "relation"; //$NON-NLS-1$
|
||||
protected static final String ELEM_MEMBER = "member"; //$NON-NLS-1$
|
||||
protected static final String ELEM_MODIFY = "modify"; //$NON-NLS-1$
|
||||
protected static final String ELEM_CREATE = "create"; //$NON-NLS-1$
|
||||
protected static final String ELEM_DELETE = "delete"; //$NON-NLS-1$
|
||||
|
||||
|
||||
protected static final String ATTR_VERSION = "version"; //$NON-NLS-1$
|
||||
|
@ -55,6 +59,7 @@ public class OsmBaseStorage extends DefaultHandler {
|
|||
protected static final String ATTR_ROLE = "role"; //$NON-NLS-1$
|
||||
|
||||
protected Entity currentParsedEntity = null;
|
||||
protected int currentModify = 0;
|
||||
protected EntityInfo currentParsedEntityInfo = null;
|
||||
|
||||
protected boolean parseStarted;
|
||||
|
@ -114,6 +119,7 @@ public class OsmBaseStorage extends DefaultHandler {
|
|||
this.supressWarnings = supressWarnings;
|
||||
}
|
||||
|
||||
private boolean osmChange;
|
||||
protected SAXParser saxParser;
|
||||
public SAXParser initSaxParser(){
|
||||
if(saxParser != null){
|
||||
|
@ -157,9 +163,10 @@ public class OsmBaseStorage extends DefaultHandler {
|
|||
}
|
||||
|
||||
protected void initRootElement(String uri, String localName, String name, Attributes attributes) throws OsmVersionNotSupported{
|
||||
if(!ELEM_OSM.equals(name) || !supportedVersions.contains(attributes.getValue(ATTR_VERSION))){
|
||||
if((!ELEM_OSM.equals(name) && !ELEM_OSMCHANGE.equals(name)) || !supportedVersions.contains(attributes.getValue(ATTR_VERSION))){
|
||||
throw new OsmVersionNotSupported();
|
||||
}
|
||||
osmChange = ELEM_OSMCHANGE.equals(name);
|
||||
parseStarted = true;
|
||||
}
|
||||
|
||||
|
@ -171,7 +178,13 @@ public class OsmBaseStorage extends DefaultHandler {
|
|||
if(!parseStarted){
|
||||
initRootElement(uri, localName, name, attributes);
|
||||
}
|
||||
if (currentParsedEntity == null) {
|
||||
if (ELEM_MODIFY.equals(name) ) {
|
||||
currentModify = Entity.MODIFY_MODIFIED;
|
||||
} else if (ELEM_CREATE.equals(name) ) {
|
||||
currentModify = Entity.MODIFY_CREATED;
|
||||
} else if (ELEM_DELETE.equals(name) ) {
|
||||
currentModify = Entity.MODIFY_DELETED;
|
||||
} else if (currentParsedEntity == null) {
|
||||
progressEntity ++;
|
||||
if(progress != null && ((progressEntity % moduleProgress) == 0) &&
|
||||
!progress.isIndeterminate() && streamForProgress != null){
|
||||
|
@ -191,7 +204,9 @@ public class OsmBaseStorage extends DefaultHandler {
|
|||
} else {
|
||||
// this situation could be logged as unhandled
|
||||
}
|
||||
if(parseEntityInfo && currentParsedEntity != null){
|
||||
if (currentParsedEntity != null) {
|
||||
currentParsedEntity.setModify(currentModify);
|
||||
if (parseEntityInfo) {
|
||||
currentParsedEntityInfo = new EntityInfo();
|
||||
currentParsedEntityInfo.setChangeset(attributes.getValue(ATTR_CHANGESET));
|
||||
currentParsedEntityInfo.setTimestamp(attributes.getValue(ATTR_TIMESTAMP));
|
||||
|
@ -200,6 +215,7 @@ public class OsmBaseStorage extends DefaultHandler {
|
|||
currentParsedEntityInfo.setVisible(attributes.getValue(ATTR_VISIBLE));
|
||||
currentParsedEntityInfo.setUid(attributes.getValue(ATTR_UID));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ELEM_TAG.equals(name)) {
|
||||
String key = attributes.getValue(ATTR_K);
|
||||
|
@ -234,6 +250,12 @@ public class OsmBaseStorage extends DefaultHandler {
|
|||
type = EntityType.WAY;
|
||||
} else if (ELEM_RELATION.equals(name)){
|
||||
type = EntityType.RELATION;
|
||||
} else if (ELEM_MODIFY.equals(name) ) {
|
||||
currentModify = 0;
|
||||
} else if (ELEM_CREATE.equals(name) ) {
|
||||
currentModify = 0;
|
||||
} else if (ELEM_DELETE.equals(name) ) {
|
||||
currentModify = 0;
|
||||
}
|
||||
if (type != null) {
|
||||
if(currentParsedEntity != null){
|
||||
|
|
Loading…
Reference in a new issue