4 changed files with 114 additions and 11 deletions
@ -1,33 +1,67 @@
|
||||
package org.leolo.map.osm.extract.model; |
||||
|
||||
import de.topobyte.osm4j.core.model.iface.OsmEntity; |
||||
import de.topobyte.osm4j.core.model.iface.OsmNode; |
||||
import de.topobyte.osm4j.core.model.iface.OsmRelation; |
||||
import de.topobyte.osm4j.core.model.iface.OsmWay; |
||||
|
||||
import java.util.HashSet; |
||||
import java.util.Set; |
||||
|
||||
public abstract class SearchItem { |
||||
|
||||
private ActionFile af; |
||||
|
||||
private HashSet<String> tagName = new HashSet<>(); |
||||
|
||||
public SearchItem(ActionFile af){ |
||||
this.af = af; |
||||
setTags(); |
||||
} |
||||
|
||||
public SearchItem(){ |
||||
//Empty constructor
|
||||
} |
||||
|
||||
protected abstract boolean matchString(String target); |
||||
protected final void setActionFile(ActionFile af){ |
||||
this.af = af; |
||||
setTags(); |
||||
} |
||||
|
||||
private void setTags(){ |
||||
tagName.add("name:"+af.getBaseLanguage()); |
||||
for(String lang:af.getOtherLanguage()){ |
||||
tagName.add("name:"+lang); |
||||
} |
||||
} |
||||
|
||||
public abstract boolean matchString(String target); |
||||
public abstract void setSearchKey(String searchKey); |
||||
|
||||
public boolean matchNode(OsmNode node){ |
||||
private boolean matchEntity(OsmEntity entity){ |
||||
for(int i=0;i<entity.getNumberOfTags();i++){ |
||||
if("name".equalsIgnoreCase(entity.getTag(i).getKey()) && matchString(entity.getTag(i).getValue())){ |
||||
return true; |
||||
} |
||||
if(af != null){ |
||||
for(String tag:tagName){ |
||||
if(tag.equalsIgnoreCase(entity.getTag(i).getKey()) && matchString(entity.getTag(i).getValue())){ |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
public boolean matchNode(OsmNode node){ |
||||
return matchEntity(node); |
||||
} |
||||
|
||||
public boolean matchWay(OsmWay way){ |
||||
return false; |
||||
return matchEntity(way); |
||||
} |
||||
|
||||
public boolean matchRelation(OsmRelation relation){ |
||||
return false; |
||||
return matchEntity(relation); |
||||
} |
||||
} |
||||
|
||||
Loading…
Reference in new issue