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
|
// test cases show info
|
||||||
if(args.length == 1 && "test".equals(args[0])) {
|
if(args.length == 1 && "test".equals(args[0])) {
|
||||||
in.inspector(new String[]{
|
in.inspector(new String[]{
|
||||||
"-vpoi",
|
// "-vpoi",
|
||||||
// "-vmap", "-vmapobjects",
|
"-vmap", "-vmapobjects",
|
||||||
// "-vrouting",
|
// "-vrouting",
|
||||||
// "-vaddress", "-vcities","-vstreetgroups",
|
// "-vaddress", "-vcities","-vstreetgroups",
|
||||||
// "-vstreets", "-vbuildings", "-vintersections",
|
// "-vstreets", "-vbuildings", "-vintersections",
|
||||||
// "-zoom=16",
|
"-zoom=14",
|
||||||
// "-bbox=1.74,51.17,1.75,51.16",
|
// "-bbox=1.74,51.17,1.75,51.16",
|
||||||
// "-vstats",
|
// "-vstats",
|
||||||
"/Users/victorshcherb/osmand/osm-gen/Synthetic_test_rendering.obf"
|
"/Users/victorshcherb/osmand/osm-gen/032.obf"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
in.inspector(args);
|
in.inspector(args);
|
||||||
|
|
|
@ -103,11 +103,18 @@ public abstract class Entity {
|
||||||
private Map<String, String> tags = null;
|
private Map<String, String> tags = null;
|
||||||
private final long id;
|
private final long id;
|
||||||
private boolean dataLoaded;
|
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) {
|
public Entity(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Entity(Entity copy, long id) {
|
public Entity(Entity copy, long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
for (String t : copy.getTagKeySet()) {
|
for (String t : copy.getTagKeySet()) {
|
||||||
|
@ -116,6 +123,14 @@ public abstract class Entity {
|
||||||
this.dataLoaded = copy.dataLoaded;
|
this.dataLoaded = copy.dataLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getModify() {
|
||||||
|
return modify;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModify(int modify) {
|
||||||
|
this.modify = modify;
|
||||||
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,16 @@ import org.xml.sax.helpers.DefaultHandler;
|
||||||
public class OsmBaseStorage extends DefaultHandler {
|
public class OsmBaseStorage extends DefaultHandler {
|
||||||
|
|
||||||
protected static final String ELEM_OSM = "osm"; //$NON-NLS-1$
|
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_NODE = "node"; //$NON-NLS-1$
|
||||||
protected static final String ELEM_TAG = "tag"; //$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_WAY = "way"; //$NON-NLS-1$
|
||||||
protected static final String ELEM_ND = "nd"; //$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_RELATION = "relation"; //$NON-NLS-1$
|
||||||
protected static final String ELEM_MEMBER = "member"; //$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$
|
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 static final String ATTR_ROLE = "role"; //$NON-NLS-1$
|
||||||
|
|
||||||
protected Entity currentParsedEntity = null;
|
protected Entity currentParsedEntity = null;
|
||||||
|
protected int currentModify = 0;
|
||||||
protected EntityInfo currentParsedEntityInfo = null;
|
protected EntityInfo currentParsedEntityInfo = null;
|
||||||
|
|
||||||
protected boolean parseStarted;
|
protected boolean parseStarted;
|
||||||
|
@ -114,6 +119,7 @@ public class OsmBaseStorage extends DefaultHandler {
|
||||||
this.supressWarnings = supressWarnings;
|
this.supressWarnings = supressWarnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean osmChange;
|
||||||
protected SAXParser saxParser;
|
protected SAXParser saxParser;
|
||||||
public SAXParser initSaxParser(){
|
public SAXParser initSaxParser(){
|
||||||
if(saxParser != null){
|
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{
|
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();
|
throw new OsmVersionNotSupported();
|
||||||
}
|
}
|
||||||
|
osmChange = ELEM_OSMCHANGE.equals(name);
|
||||||
parseStarted = true;
|
parseStarted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +178,13 @@ public class OsmBaseStorage extends DefaultHandler {
|
||||||
if(!parseStarted){
|
if(!parseStarted){
|
||||||
initRootElement(uri, localName, name, attributes);
|
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 ++;
|
progressEntity ++;
|
||||||
if(progress != null && ((progressEntity % moduleProgress) == 0) &&
|
if(progress != null && ((progressEntity % moduleProgress) == 0) &&
|
||||||
!progress.isIndeterminate() && streamForProgress != null){
|
!progress.isIndeterminate() && streamForProgress != null){
|
||||||
|
@ -191,14 +204,17 @@ public class OsmBaseStorage extends DefaultHandler {
|
||||||
} else {
|
} else {
|
||||||
// this situation could be logged as unhandled
|
// this situation could be logged as unhandled
|
||||||
}
|
}
|
||||||
if(parseEntityInfo && currentParsedEntity != null){
|
if (currentParsedEntity != null) {
|
||||||
currentParsedEntityInfo = new EntityInfo();
|
currentParsedEntity.setModify(currentModify);
|
||||||
currentParsedEntityInfo.setChangeset(attributes.getValue(ATTR_CHANGESET));
|
if (parseEntityInfo) {
|
||||||
currentParsedEntityInfo.setTimestamp(attributes.getValue(ATTR_TIMESTAMP));
|
currentParsedEntityInfo = new EntityInfo();
|
||||||
currentParsedEntityInfo.setUser(attributes.getValue(ATTR_USER));
|
currentParsedEntityInfo.setChangeset(attributes.getValue(ATTR_CHANGESET));
|
||||||
currentParsedEntityInfo.setVersion(attributes.getValue(ATTR_VERSION));
|
currentParsedEntityInfo.setTimestamp(attributes.getValue(ATTR_TIMESTAMP));
|
||||||
currentParsedEntityInfo.setVisible(attributes.getValue(ATTR_VISIBLE));
|
currentParsedEntityInfo.setUser(attributes.getValue(ATTR_USER));
|
||||||
currentParsedEntityInfo.setUid(attributes.getValue(ATTR_UID));
|
currentParsedEntityInfo.setVersion(attributes.getValue(ATTR_VERSION));
|
||||||
|
currentParsedEntityInfo.setVisible(attributes.getValue(ATTR_VISIBLE));
|
||||||
|
currentParsedEntityInfo.setUid(attributes.getValue(ATTR_UID));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ELEM_TAG.equals(name)) {
|
if (ELEM_TAG.equals(name)) {
|
||||||
|
@ -234,6 +250,12 @@ public class OsmBaseStorage extends DefaultHandler {
|
||||||
type = EntityType.WAY;
|
type = EntityType.WAY;
|
||||||
} else if (ELEM_RELATION.equals(name)){
|
} else if (ELEM_RELATION.equals(name)){
|
||||||
type = EntityType.RELATION;
|
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 (type != null) {
|
||||||
if(currentParsedEntity != null){
|
if(currentParsedEntity != null){
|
||||||
|
|
Loading…
Reference in a new issue