Fix some issues
This commit is contained in:
parent
227066041d
commit
c771a68380
3 changed files with 24 additions and 24 deletions
|
@ -147,7 +147,10 @@ public class MapPoiTypes {
|
|||
Map<String, PoiType> translation = new HashMap<String, PoiType>();
|
||||
for(PoiCategory pc : categories) {
|
||||
for(PoiType pt : pc.getPoiTypes()) {
|
||||
if(pt.isReference() || pt.isNotEditableOsm()) {
|
||||
if(pt.isReference() ) {
|
||||
continue;
|
||||
}
|
||||
if(skipNonEditable || pt.isNotEditableOsm()) {
|
||||
continue;
|
||||
}
|
||||
translation.put(pt.getKeyName().replace('_', ' ').toLowerCase(), pt);
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.osmand.data.Amenity;
|
|||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.osm.edit.OSMSettings;
|
||||
import net.osmand.osm.edit.OSMSettings.OSMTagKey;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -20,20 +21,31 @@ public class EditPoiData {
|
|||
private Set<TagsChangedListener> mListeners = new HashSet<>();
|
||||
private LinkedHashMap<String, String > tagValues = new LinkedHashMap<String, String>();
|
||||
private boolean isInEdit = false;
|
||||
private Node entity;
|
||||
public final Amenity amenity;
|
||||
public static final String POI_TYPE_TAG = "poi_type_tag";
|
||||
private boolean hasChangesBeenMade = false;
|
||||
|
||||
public EditPoiData(Amenity amenity, Node node, Map<String, PoiType> allTranslatedSubTypes) {
|
||||
this.amenity = amenity;
|
||||
entity = node;
|
||||
initTags(node, allTranslatedSubTypes);
|
||||
}
|
||||
|
||||
|
||||
public Node getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public String getTag(String key) {
|
||||
return tagValues.get(key);
|
||||
}
|
||||
|
||||
public void updateTags(Map<String, String> mp) {
|
||||
this.tagValues.clear();
|
||||
this.tagValues.putAll(mp);
|
||||
}
|
||||
|
||||
private void tryAddTag(String key, String value) {
|
||||
if (!Algorithms.isEmpty(value)) {
|
||||
tagValues.put(key, value);
|
||||
|
@ -42,18 +54,6 @@ public class EditPoiData {
|
|||
|
||||
private void initTags(Node node, Map<String, PoiType> allTranslatedSubTypes) {
|
||||
checkNotInEdit();
|
||||
// tryAddTag(OSMSettings.OSMTagKey.ADDR_STREET.getValue(),
|
||||
// node.getTag(OSMSettings.OSMTagKey.ADDR_STREET));
|
||||
// tryAddTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue(),
|
||||
// node.getTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER));
|
||||
// should not be used here should be done in public Node loadNode(Amenity n) {
|
||||
// tryAddTag(OSMSettings.OSMTagKey.PHONE.getValue(),
|
||||
// amenity.getPhone());
|
||||
// tryAddTag(OSMSettings.OSMTagKey.WEBSITE.getValue(),
|
||||
// amenity.getSite());
|
||||
// for (String tag : amenity.getAdditionalInfo().keySet()) {
|
||||
// tryAddTag(tag, amenity.getAdditionalInfo(tag));
|
||||
// }
|
||||
for (String s : node.getTagKeySet()) {
|
||||
tryAddTag(s, node.getTag(s));
|
||||
}
|
||||
|
@ -146,4 +146,5 @@ public class EditPoiData {
|
|||
public boolean hasChangesBeenMade() {
|
||||
return hasChangesBeenMade;
|
||||
}
|
||||
|
||||
}
|
|
@ -82,7 +82,6 @@ public class EditPoiDialogFragment extends DialogFragment {
|
|||
private EditPoiData editPoiData;
|
||||
private ViewPager viewPager;
|
||||
private AutoCompleteTextView poiTypeEditText;
|
||||
private Node node;
|
||||
private Map<String, PoiType> allTranslatedSubTypes;
|
||||
|
||||
private OpenstreetmapUtil mOpenstreetmapUtil;
|
||||
|
@ -99,7 +98,7 @@ public class EditPoiDialogFragment extends DialogFragment {
|
|||
mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity);
|
||||
}
|
||||
|
||||
node = (Node) getArguments().getSerializable(KEY_AMENITY_NODE);
|
||||
Node node = (Node) getArguments().getSerializable(KEY_AMENITY_NODE);
|
||||
allTranslatedSubTypes = getMyApplication().getPoiTypes().getAllTranslatedNames(true);
|
||||
|
||||
Amenity amenity = (Amenity) getArguments().getSerializable(KEY_AMENITY);
|
||||
|
@ -229,7 +228,7 @@ public class EditPoiDialogFragment extends DialogFragment {
|
|||
}
|
||||
}
|
||||
});
|
||||
poiNameEditText.setText(node.getTag(OSMSettings.OSMTagKey.NAME));
|
||||
poiNameEditText.setText(editPoiData.getTag(OSMSettings.OSMTagKey.NAME.getValue()));
|
||||
poiTypeTextInputLayout = (TextInputLayout) view.findViewById(R.id.poiTypeTextInputLayout);
|
||||
poiTypeEditText = (AutoCompleteTextView) view.findViewById(R.id.poiTypeEditText);
|
||||
poiTypeEditText.addTextChangedListener(new TextWatcher() {
|
||||
|
@ -286,6 +285,8 @@ public class EditPoiDialogFragment extends DialogFragment {
|
|||
poiTypeEditText.setError(getResources().getString(R.string.please_specify_poi_type));
|
||||
return;
|
||||
}
|
||||
Node original = editPoiData.getEntity();
|
||||
Node node = new Node(original.getLatitude(), original.getLongitude(), original.getId());
|
||||
OsmPoint.Action action = node.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
|
||||
for (Map.Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
|
||||
if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) {
|
||||
|
@ -297,15 +298,10 @@ public class EditPoiDialogFragment extends DialogFragment {
|
|||
}
|
||||
} else {
|
||||
node.putTag(editPoiData.amenity.getType().getDefaultTag(), tag.getValue());
|
||||
|
||||
}
|
||||
// } else if (tag.tag.equals(OSMSettings.OSMTagKey.DESCRIPTION.getValue())) {
|
||||
// description = tag.value;
|
||||
} else {
|
||||
if (tag.getKey().length() > 0) {
|
||||
node.putTag(tag.getKey(), tag.getValue());
|
||||
} else {
|
||||
node.removeTag(tag.getKey());
|
||||
}
|
||||
} else if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue())) {
|
||||
node.putTag(tag.getKey(), tag.getValue());
|
||||
}
|
||||
}
|
||||
commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(),
|
||||
|
|
Loading…
Reference in a new issue