Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
50fbb4cd3e
5 changed files with 110 additions and 48 deletions
|
@ -401,7 +401,7 @@ public class BinaryMapTransportReaderAdapter {
|
||||||
int filePointer) throws IOException {
|
int filePointer) throws IOException {
|
||||||
TransportStop dataObject = new TransportStop();
|
TransportStop dataObject = new TransportStop();
|
||||||
dataObject.setFileOffset(codedIS.getTotalBytesRead());
|
dataObject.setFileOffset(codedIS.getTotalBytesRead());
|
||||||
dataObject.setReferencesToRoutes(new int[] {filePointer});
|
// dataObject.setReferencesToRoutes(new int[] {filePointer});
|
||||||
boolean end = false;
|
boolean end = false;
|
||||||
while(!end){
|
while(!end){
|
||||||
int t = codedIS.readTag();
|
int t = codedIS.readTag();
|
||||||
|
|
|
@ -5,9 +5,11 @@ import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.MapObject;
|
import net.osmand.data.MapObject;
|
||||||
import net.osmand.data.QuadPoint;
|
import net.osmand.data.QuadPoint;
|
||||||
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.util.GeoPointParserUtil.GeoParsedPoint;
|
import net.osmand.util.GeoPointParserUtil.GeoParsedPoint;
|
||||||
|
|
||||||
|
|
||||||
|
@ -534,6 +536,25 @@ public class MapUtils {
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static QuadRect calculateLatLonBbox(double latitude, double longitude, int radiusMeters) {
|
||||||
|
int zoom = 16;
|
||||||
|
float coeff = (float) (radiusMeters / MapUtils.getTileDistanceWidth(zoom));
|
||||||
|
double tx = MapUtils.getTileNumberX(zoom, longitude);
|
||||||
|
double ty = MapUtils.getTileNumberY(zoom, latitude);
|
||||||
|
double topLeftX = Math.max(0, tx - coeff);
|
||||||
|
double topLeftY = Math.max(0, ty - coeff);
|
||||||
|
int max = (1 << zoom) - 1;
|
||||||
|
double bottomRightX = Math.min(max, tx + coeff);
|
||||||
|
double bottomRightY = Math.min(max, ty + coeff);
|
||||||
|
double pw = MapUtils.getPowZoom(31 - zoom);
|
||||||
|
QuadRect rect = new QuadRect(topLeftX * pw, topLeftY * pw, bottomRightX * pw, bottomRightY * pw);
|
||||||
|
rect.left = MapUtils.get31LongitudeX((int) rect.left);
|
||||||
|
rect.top = MapUtils.get31LatitudeY((int) rect.top);
|
||||||
|
rect.right = MapUtils.get31LongitudeX((int) rect.right);
|
||||||
|
rect.bottom = MapUtils.get31LatitudeY((int) rect.bottom);
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -595,6 +595,7 @@ public class ConfigureMapMenu {
|
||||||
for (int i = 0; i < prefs.size(); i++) {
|
for (int i = 0; i < prefs.size(); i++) {
|
||||||
prefs.get(i).set(false);
|
prefs.get(i).set(false);
|
||||||
}
|
}
|
||||||
|
adapter.getItem(pos).setColorRes(ContextMenuItem.INVALID_ID);
|
||||||
a.notifyDataSetInvalidated();
|
a.notifyDataSetInvalidated();
|
||||||
refreshMapComplete(activity);
|
refreshMapComplete(activity);
|
||||||
activity.getMapLayers().updateLayers(activity.getMapView());
|
activity.getMapLayers().updateLayers(activity.getMapView());
|
||||||
|
@ -636,6 +637,7 @@ public class ConfigureMapMenu {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
builder.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||||
builder.setSelected(selected);
|
builder.setSelected(selected);
|
||||||
}
|
}
|
||||||
return builder.createItem();
|
return builder.createItem();
|
||||||
|
@ -686,7 +688,18 @@ public class ConfigureMapMenu {
|
||||||
|
|
||||||
bld.setTitle(category);
|
bld.setTitle(category);
|
||||||
|
|
||||||
bld.setNegativeButton(R.string.shared_string_cancel, null);
|
bld.setNegativeButton(R.string.shared_string_cancel, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
|
boolean selected = false;
|
||||||
|
for (int i = 0; i < prefs.size(); i++) {
|
||||||
|
prefs.get(i).set(tempPrefs[i]);
|
||||||
|
selected |= tempPrefs[i];
|
||||||
|
}
|
||||||
|
adapter.getItem(pos).setSelected(selected);
|
||||||
|
adapter.getItem(pos).setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||||
|
a.notifyDataSetInvalidated();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
|
@ -700,6 +713,7 @@ public class ConfigureMapMenu {
|
||||||
adapter.getItem(pos).setDescription(getDescription(prefs));
|
adapter.getItem(pos).setDescription(getDescription(prefs));
|
||||||
} else{
|
} else{
|
||||||
adapter.getItem(pos).setSelected(selected);
|
adapter.getItem(pos).setSelected(selected);
|
||||||
|
adapter.getItem(pos).setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a.notifyDataSetInvalidated();
|
a.notifyDataSetInvalidated();
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package net.osmand.plus.mapcontextmenu.controllers;
|
package net.osmand.plus.mapcontextmenu.controllers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.data.TransportRoute;
|
import net.osmand.data.TransportRoute;
|
||||||
import net.osmand.data.TransportStop;
|
import net.osmand.data.TransportStop;
|
||||||
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -18,6 +21,7 @@ import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
import net.osmand.plus.resources.TransportIndexRepository;
|
import net.osmand.plus.resources.TransportIndexRepository;
|
||||||
import net.osmand.plus.views.TransportStopsLayer;
|
import net.osmand.plus.views.TransportStopsLayer;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
import net.osmand.util.MapUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
|
||||||
|
@ -123,7 +127,8 @@ public class TransportStopController extends MenuController {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View arg0) {
|
public void onClick(View arg0) {
|
||||||
MapContextMenu mm = getMapActivity().getContextMenu();
|
MapContextMenu mm = getMapActivity().getContextMenu();
|
||||||
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, r.desc);
|
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
|
||||||
|
r.getDescription(getMapActivity().getMyApplication(), false));
|
||||||
mm.show(latLon, pd, r);
|
mm.show(latLon, pd, r);
|
||||||
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
|
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
|
||||||
stopsLayer.setRoute(r.route);
|
stopsLayer.setRoute(r.route);
|
||||||
|
@ -132,9 +137,11 @@ public class TransportStopController extends MenuController {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (r.type == null) {
|
if (r.type == null) {
|
||||||
addPlainMenuItem(R.drawable.ic_action_polygom_dark, r.desc, false, false, listener );
|
addPlainMenuItem(R.drawable.ic_action_polygom_dark, r.getDescription(getMapActivity().getMyApplication(), true),
|
||||||
|
false, false, listener );
|
||||||
} else {
|
} else {
|
||||||
addPlainMenuItem(r.type.getResourceId(), r.desc, false, false, listener);
|
addPlainMenuItem(r.type.getResourceId(), r.getDescription(getMapActivity().getMyApplication(), true),
|
||||||
|
false, false, listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
super.addPlainMenuItems(typeStr, pointDescription, latLon);
|
||||||
|
@ -150,32 +157,54 @@ public class TransportStopController extends MenuController {
|
||||||
|
|
||||||
for (TransportIndexRepository t : reps) {
|
for (TransportIndexRepository t : reps) {
|
||||||
if (t.acceptTransportStop(transportStop)) {
|
if (t.acceptTransportStop(transportStop)) {
|
||||||
Collection<TransportRoute> rts = t.getRouteForStop(transportStop);
|
addRoutes(useEnglishNames, t, transportStop, 0);
|
||||||
if (rts != null) {
|
ArrayList<TransportStop> ls = new ArrayList<>();
|
||||||
for (TransportRoute rs : rts) {
|
QuadRect ll = MapUtils.calculateLatLonBbox(transportStop.getLocation().getLatitude(), transportStop.getLocation().getLongitude(), 150);
|
||||||
TransportStopType type = TransportStopType.findType(rs.getType());
|
t.searchTransportStops(ll.top, ll.left, ll.bottom, ll.right, -1, ls, null);
|
||||||
TransportStopRoute r = new TransportStopRoute();
|
for(TransportStop tstop : ls) {
|
||||||
if (topType == null && type != null && type.isTopType()) {
|
if(tstop.getId() != transportStop.getId() || !Arrays.equals(tstop.getReferencesToRoutes(),
|
||||||
topType = type;
|
transportStop.getReferencesToRoutes())) {
|
||||||
}
|
addRoutes(useEnglishNames, t, tstop, (int) MapUtils.getDistance(tstop.getLocation(), transportStop.getLocation()));
|
||||||
r.type = type;
|
|
||||||
r.desc = rs.getRef() + " " + (useEnglishNames ? rs.getEnName(true) : rs.getName());
|
|
||||||
r.route = rs;
|
|
||||||
r.stop = transportStop;
|
|
||||||
this.routes.add(r);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addRoutes(boolean useEnglishNames, TransportIndexRepository t, TransportStop s, int dist) {
|
||||||
|
Collection<TransportRoute> rts = t.getRouteForStop(s);
|
||||||
|
if (rts != null) {
|
||||||
|
for (TransportRoute rs : rts) {
|
||||||
|
TransportStopType type = TransportStopType.findType(rs.getType());
|
||||||
|
TransportStopRoute r = new TransportStopRoute();
|
||||||
|
if (topType == null && type != null && type.isTopType()) {
|
||||||
|
topType = type;
|
||||||
|
}
|
||||||
|
r.type = type;
|
||||||
|
r.desc = rs.getRef() + " " + (useEnglishNames ? rs.getEnName(true) : rs.getName());
|
||||||
|
r.route = rs;
|
||||||
|
r.stop = s;
|
||||||
|
r.distance = dist;
|
||||||
|
this.routes.add(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class TransportStopRoute {
|
public static class TransportStopRoute {
|
||||||
public TransportStopType type;
|
public TransportStopType type;
|
||||||
public String desc;
|
public String desc;
|
||||||
public TransportRoute route;
|
public TransportRoute route;
|
||||||
public TransportStop stop;
|
public TransportStop stop;
|
||||||
|
public int distance;
|
||||||
public boolean showWholeRoute;
|
public boolean showWholeRoute;
|
||||||
|
|
||||||
|
public String getDescription(OsmandApplication ctx, boolean useDistance) {
|
||||||
|
if(useDistance && distance > 0) {
|
||||||
|
return desc +" (" + OsmAndFormatter.getFormattedDistance(distance, ctx) +")";
|
||||||
|
}
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
public int calculateZoom(int startPosition, RotatedTileBox currentRotatedTileBox) {
|
public int calculateZoom(int startPosition, RotatedTileBox currentRotatedTileBox) {
|
||||||
RotatedTileBox cp = currentRotatedTileBox.copy();
|
RotatedTileBox cp = currentRotatedTileBox.copy();
|
||||||
boolean notContains = true;
|
boolean notContains = true;
|
||||||
|
|
|
@ -1,5 +1,33 @@
|
||||||
package net.osmand.plus.osmedit;
|
package net.osmand.plus.osmedit;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.osmand.CallbackWithObject;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.data.Amenity;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.osm.PoiCategory;
|
||||||
|
import net.osmand.osm.PoiType;
|
||||||
|
import net.osmand.osm.edit.EntityInfo;
|
||||||
|
import net.osmand.osm.edit.Node;
|
||||||
|
import net.osmand.osm.edit.OSMSettings;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
||||||
|
import net.osmand.plus.osmedit.dialogs.PoiSubTypeDialogFragment;
|
||||||
|
import net.osmand.plus.osmedit.dialogs.PoiTypeDialogFragment;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
@ -46,34 +74,6 @@ import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.CallbackWithObject;
|
|
||||||
import net.osmand.PlatformUtil;
|
|
||||||
import net.osmand.data.Amenity;
|
|
||||||
import net.osmand.data.LatLon;
|
|
||||||
import net.osmand.osm.PoiCategory;
|
|
||||||
import net.osmand.osm.PoiType;
|
|
||||||
import net.osmand.osm.edit.EntityInfo;
|
|
||||||
import net.osmand.osm.edit.Node;
|
|
||||||
import net.osmand.osm.edit.OSMSettings;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandPlugin;
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
|
||||||
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
|
||||||
import net.osmand.plus.osmedit.dialogs.PoiSubTypeDialogFragment;
|
|
||||||
import net.osmand.plus.osmedit.dialogs.PoiTypeDialogFragment;
|
|
||||||
import net.osmand.util.Algorithms;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
public static final String TAG = "EditPoiDialogFragment";
|
public static final String TAG = "EditPoiDialogFragment";
|
||||||
private static final Log LOG = PlatformUtil.getLog(EditPoiDialogFragment.class);
|
private static final Log LOG = PlatformUtil.getLog(EditPoiDialogFragment.class);
|
||||||
|
@ -192,8 +192,6 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
|
|
||||||
ViewTreeObserver obs = view.getViewTreeObserver();
|
ViewTreeObserver obs = view.getViewTreeObserver();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
obs.removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
obs.removeGlobalOnLayoutListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue