Implement multi objects context menu. Add wiki scripts
This commit is contained in:
parent
77f9064258
commit
a92f33aee1
8 changed files with 172 additions and 91 deletions
|
@ -299,7 +299,7 @@ public class WikiIndexer {
|
||||||
}
|
}
|
||||||
} else if (name.equals("text")) {
|
} else if (name.equals("text")) {
|
||||||
if(parseText) {
|
if(parseText) {
|
||||||
if(id % 50 == 0) {
|
if(id % 100 == 0) {
|
||||||
log.debug("Article accepted " + cid + " " + title.toString());
|
log.debug("Article accepted " + cid + " " + title.toString());
|
||||||
}
|
}
|
||||||
analyzeTextForGeoInfoNew();
|
analyzeTextForGeoInfoNew();
|
||||||
|
|
|
@ -6,6 +6,8 @@ import java.util.List;
|
||||||
import net.osmand.osm.LatLon;
|
import net.osmand.osm.LatLon;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
import android.content.DialogInterface.OnClickListener;
|
||||||
|
@ -28,7 +30,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
public interface IContextMenuProvider {
|
public interface IContextMenuProvider {
|
||||||
|
|
||||||
public Object getPointObject(PointF point);
|
public void collectObjectsFromPoint(PointF point, List<Object> o);
|
||||||
|
|
||||||
public LatLon getObjectLocation(Object o);
|
public LatLon getObjectLocation(Object o);
|
||||||
|
|
||||||
|
@ -42,7 +44,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private LatLon latLon;
|
private LatLon latLon;
|
||||||
private IContextMenuProvider selectedContextProvider;
|
private IContextMenuProvider selectedContextProvider;
|
||||||
private Object selectedObject;
|
private List<Object> selectedObjects = new ArrayList<Object>();
|
||||||
|
|
||||||
private TextView textView;
|
private TextView textView;
|
||||||
private DisplayMetrics dm;
|
private DisplayMetrics dm;
|
||||||
|
@ -157,11 +159,11 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedContextProvider = null;
|
selectedContextProvider = null;
|
||||||
selectedObject = null;
|
selectedObjects.clear();
|
||||||
for(OsmandMapLayer l : view.getLayers()){
|
for(OsmandMapLayer l : view.getLayers()){
|
||||||
if(l instanceof ContextMenuLayer.IContextMenuProvider){
|
if(l instanceof ContextMenuLayer.IContextMenuProvider){
|
||||||
selectedObject = ((ContextMenuLayer.IContextMenuProvider) l).getPointObject(point);
|
((ContextMenuLayer.IContextMenuProvider) l).collectObjectsFromPoint(point, selectedObjects);
|
||||||
if(selectedObject != null){
|
if(!selectedObjects.isEmpty()){
|
||||||
selectedContextProvider = (IContextMenuProvider) l;
|
selectedContextProvider = (IContextMenuProvider) l;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -169,16 +171,18 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
LatLon latLon = view.getLatLonFromScreenPoint(point.x, point.y);
|
LatLon latLon = view.getLatLonFromScreenPoint(point.x, point.y);
|
||||||
String description = "";
|
StringBuilder description = new StringBuilder();
|
||||||
|
|
||||||
if(selectedObject != null){
|
if(!selectedObjects.isEmpty()){
|
||||||
description = selectedContextProvider.getObjectDescription(selectedObject);
|
for(Object o : selectedObjects) {
|
||||||
LatLon l = selectedContextProvider.getObjectLocation(selectedObject);
|
description.append(selectedContextProvider.getObjectDescription(o));
|
||||||
|
}
|
||||||
|
LatLon l = selectedContextProvider.getObjectLocation(selectedObjects.get(0));
|
||||||
if(l != null){
|
if(l != null){
|
||||||
latLon = l;
|
latLon = l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setLocation(latLon, description);
|
setLocation(latLon, description.toString());
|
||||||
view.refreshMap();
|
view.refreshMap();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -203,8 +207,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSelectedObjectName(){
|
public String getSelectedObjectName(){
|
||||||
if(selectedObject != null && selectedContextProvider != null){
|
if(!selectedObjects.isEmpty() && selectedContextProvider != null){
|
||||||
return selectedContextProvider.getObjectName(selectedObject);
|
return selectedContextProvider.getObjectName(selectedObjects);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -212,10 +216,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
@Override
|
@Override
|
||||||
public boolean onSingleTap(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
if (pressedInTextView(point.x, point.y)) {
|
if (pressedInTextView(point.x, point.y)) {
|
||||||
if (selectedObject != null) {
|
if (!selectedObjects.isEmpty()) {
|
||||||
ArrayList<String> l = new ArrayList<String>();
|
showContextMenuForSelectedObjects();
|
||||||
OnClickListener listener = selectedContextProvider.getActionListener(l, selectedObject);
|
|
||||||
activity.contextMenuPoint(latLon.getLatitude(), latLon.getLongitude(), l, listener);
|
|
||||||
} else {
|
} else {
|
||||||
activity.contextMenuPoint(latLon.getLatitude(), latLon.getLongitude());
|
activity.contextMenuPoint(latLon.getLatitude(), latLon.getLongitude());
|
||||||
}
|
}
|
||||||
|
@ -224,6 +226,32 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showContextMenuForSelectedObjects() {
|
||||||
|
if(selectedObjects.size() > 1){
|
||||||
|
Builder builder = new AlertDialog.Builder(view.getContext());
|
||||||
|
String[] d = new String[selectedObjects.size()];
|
||||||
|
int i =0;
|
||||||
|
for(Object o : selectedObjects) {
|
||||||
|
d[i++] = selectedContextProvider.getObjectDescription(o);
|
||||||
|
}
|
||||||
|
builder.setItems(d, new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// single selection at 0
|
||||||
|
selectedObjects.set(0, selectedObjects.get(which));
|
||||||
|
ArrayList<String> l = new ArrayList<String>();
|
||||||
|
OnClickListener listener = selectedContextProvider.getActionListener(l, selectedObjects.get(0));
|
||||||
|
activity.contextMenuPoint(latLon.getLatitude(), latLon.getLongitude(), l, listener);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.show();
|
||||||
|
} else {
|
||||||
|
ArrayList<String> l = new ArrayList<String>();
|
||||||
|
OnClickListener listener = selectedContextProvider.getActionListener(l, selectedObjects.get(0));
|
||||||
|
activity.contextMenuPoint(latLon.getLatitude(), latLon.getLongitude(), l, listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.FavouritePoint;
|
import net.osmand.FavouritePoint;
|
||||||
|
@ -21,7 +22,6 @@ import android.widget.Toast;
|
||||||
public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
||||||
|
|
||||||
private static final int startZoom = 6;
|
private static final int startZoom = 6;
|
||||||
private static final int radius = 15;
|
|
||||||
|
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
private Paint paint;
|
private Paint paint;
|
||||||
|
@ -86,9 +86,8 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FavouritePoint getFavoriteFromPoint(PointF point) {
|
public void getFavoriteFromPoint(PointF point, List<? super FavouritePoint> res) {
|
||||||
FavouritePoint result = null;
|
float r = 80;
|
||||||
float r = 100;
|
|
||||||
int ex = (int) point.x;
|
int ex = (int) point.x;
|
||||||
int ey = (int) point.y;
|
int ey = (int) point.y;
|
||||||
int w = favoriteIcon.getWidth() / 2;
|
int w = favoriteIcon.getWidth() / 2;
|
||||||
|
@ -98,21 +97,26 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
||||||
int y = view.getRotatedMapYForPoint(n.getLatitude(), n.getLongitude());
|
int y = view.getRotatedMapYForPoint(n.getLatitude(), n.getLongitude());
|
||||||
if (Math.abs(x - ex) <= w && y - ey <= h && y - ey >= 0) {
|
if (Math.abs(x - ex) <= w && y - ey <= h && y - ey >= 0) {
|
||||||
float newr = Math.max(Math.abs(x - ex), Math.abs(y - ey));
|
float newr = Math.max(Math.abs(x - ex), Math.abs(y - ey));
|
||||||
if(newr < r){
|
if (newr < r) {
|
||||||
r = newr;
|
res.add(n);
|
||||||
result = n;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onSingleTap(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
FavouritePoint fav = getFavoriteFromPoint(point);
|
List<FavouritePoint> favs = new ArrayList<FavouritePoint>();
|
||||||
if(fav != null){
|
getFavoriteFromPoint(point, favs);
|
||||||
String format = view.getContext().getString(R.string.favorite) + " : " + fav.getName(); //$NON-NLS-1$
|
if(!favs.isEmpty()){
|
||||||
Toast.makeText(view.getContext(), format, Toast.LENGTH_LONG).show();
|
StringBuilder res = new StringBuilder();
|
||||||
|
for(FavouritePoint fav : favs) {
|
||||||
|
if(favs.size() > 1) {
|
||||||
|
res.append("\n");
|
||||||
|
}
|
||||||
|
res.append(view.getContext().getString(R.string.favorite) + " : " + fav.getName()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
Toast.makeText(view.getContext(), res.toString(), Toast.LENGTH_LONG).show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -142,8 +146,8 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getPointObject(PointF point) {
|
public void collectObjectsFromPoint(PointF point, List<Object> res) {
|
||||||
return getFavoriteFromPoint(point);
|
getFavoriteFromPoint(point, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -197,35 +197,41 @@ public class OsmBugsLayer extends OsmandMapLayer implements ContextMenuLayer.ICo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpenStreetBug getBugFromPoint(PointF point){
|
public void getBugFromPoint(PointF point, List<? super OpenStreetBug> res){
|
||||||
OpenStreetBug result = null;
|
|
||||||
if (objects != null && view != null) {
|
if (objects != null && view != null) {
|
||||||
int ex = (int) point.x;
|
int ex = (int) point.x;
|
||||||
int ey = (int) point.y;
|
int ey = (int) point.y;
|
||||||
int radius = getRadiusBug(view.getZoom()) * 3 / 2;
|
int radius = getRadiusBug(view.getZoom()) * 3 / 2;
|
||||||
|
int small = getRadiusBug(view.getZoom()) * 3 / 4;
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < objects.size(); i++) {
|
for (int i = 0; i < objects.size(); i++) {
|
||||||
OpenStreetBug n = objects.get(i);
|
OpenStreetBug n = objects.get(i);
|
||||||
int x = view.getRotatedMapXForPoint(n.getLatitude(), n.getLongitude());
|
int x = view.getRotatedMapXForPoint(n.getLatitude(), n.getLongitude());
|
||||||
int y = view.getRotatedMapYForPoint(n.getLatitude(), n.getLongitude());
|
int y = view.getRotatedMapYForPoint(n.getLatitude(), n.getLongitude());
|
||||||
if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {
|
if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {
|
||||||
radius = Math.max(Math.abs(x - ex), Math.abs(y - ey));
|
radius = small;
|
||||||
result = n;
|
res.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
// that's really rare case, but is much efficient than introduce synchronized block
|
// that's really rare case, but is much efficient than introduce synchronized block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onSingleTap(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
OpenStreetBug bug = getBugFromPoint(point);
|
ArrayList<OpenStreetBug> list = new ArrayList<OpenStreetBug>();
|
||||||
if(bug != null){
|
getBugFromPoint(point, list);
|
||||||
String format = activity.getString(R.string.osb_bug_name)+ " : " + bug.getName(); //$NON-NLS-1$
|
if(!list.isEmpty()){
|
||||||
Toast.makeText(activity, format, Toast.LENGTH_LONG).show();
|
StringBuilder res = new StringBuilder();
|
||||||
|
for(OpenStreetBug o : list) {
|
||||||
|
if(list.size() > 1) {
|
||||||
|
res.append("\n");
|
||||||
|
}
|
||||||
|
res.append(activity.getString(R.string.osb_bug_name)+ " : " + o.getName()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
Toast.makeText(activity, res.toString(), Toast.LENGTH_LONG).show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -475,8 +481,8 @@ public class OsmBugsLayer extends OsmandMapLayer implements ContextMenuLayer.ICo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getPointObject(PointF point) {
|
public void collectObjectsFromPoint(PointF point, List<Object> res) {
|
||||||
return getBugFromPoint(point);
|
getBugFromPoint(point, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
private Paint point;
|
private Paint point;
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
private List<Amenity> objects = new ArrayList<Amenity>();
|
private List<Amenity> objects = new ArrayList<Amenity>();
|
||||||
|
private final static int MAXIMUM_SHOW_AMENITIES = 5;
|
||||||
|
|
||||||
private ResourceManager resourceManager;
|
private ResourceManager resourceManager;
|
||||||
private PoiFilter filter;
|
private PoiFilter filter;
|
||||||
|
@ -66,46 +67,53 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Amenity getAmenityFromPoint(PointF point){
|
public void getAmenityFromPoint(PointF point, List<? super Amenity> am){
|
||||||
Amenity result = null;
|
|
||||||
if (objects != null) {
|
if (objects != null) {
|
||||||
int ex = (int) point.x;
|
int ex = (int) point.x;
|
||||||
int ey = (int) point.y;
|
int ey = (int) point.y;
|
||||||
|
int compare = getRadiusPoi(view.getZoom());
|
||||||
int radius = getRadiusPoi(view.getZoom()) * 3 / 2;
|
int radius = getRadiusPoi(view.getZoom()) * 3 / 2;
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < objects.size(); i++) {
|
for (int i = 0; i < objects.size(); i++) {
|
||||||
Amenity n = objects.get(i);
|
Amenity n = objects.get(i);
|
||||||
int x = view.getRotatedMapXForPoint(n.getLocation().getLatitude(), n.getLocation().getLongitude());
|
int x = view.getRotatedMapXForPoint(n.getLocation().getLatitude(), n.getLocation().getLongitude());
|
||||||
int y = view.getRotatedMapYForPoint(n.getLocation().getLatitude(), n.getLocation().getLongitude());
|
int y = view.getRotatedMapYForPoint(n.getLocation().getLatitude(), n.getLocation().getLongitude());
|
||||||
if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {
|
if (Math.abs(x - ex) <= compare && Math.abs(y - ey) <= compare) {
|
||||||
radius = Math.max(Math.abs(x - ex), Math.abs(y - ey));
|
compare = radius;
|
||||||
result = n;
|
am.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
// that's really rare case, but is much efficient than introduce synchronized block
|
// that's really rare case, but is much efficient than introduce synchronized block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onSingleTap(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
Amenity n = getAmenityFromPoint(point);
|
List<Amenity> am = new ArrayList<Amenity>();
|
||||||
if(n != null){
|
getAmenityFromPoint(point, am);
|
||||||
String format = OsmAndFormatter.getPoiSimpleFormat(n, view.getContext(),
|
if(!am.isEmpty()){
|
||||||
view.getSettings().USE_ENGLISH_NAMES.get());
|
StringBuilder res = new StringBuilder();
|
||||||
if(n.getOpeningHours() != null){
|
for (int i = 0; i < MAXIMUM_SHOW_AMENITIES && i < am.size(); i++) {
|
||||||
format += "\n" + view.getContext().getString(R.string.opening_hours) +" : "+ n.getOpeningHours(); //$NON-NLS-1$ //$NON-NLS-2$
|
Amenity n = am.get(i);
|
||||||
|
if (i > 0) {
|
||||||
|
res.append("\n ");
|
||||||
|
}
|
||||||
|
String format = OsmAndFormatter.getPoiSimpleFormat(n, view.getContext(), view.getSettings().USE_ENGLISH_NAMES.get());
|
||||||
|
res.append(" " + format);
|
||||||
|
if (n.getOpeningHours() != null) {
|
||||||
|
res.append("\n").append(view.getContext().getString(R.string.opening_hours)).append(" : ").append(n.getOpeningHours()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
if (n.getPhone() != null) {
|
||||||
|
res.append("\n").append(view.getContext().getString(R.string.phone)).append(" : ").append(n.getPhone()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
if (n.getSite() != null) {
|
||||||
|
res.append("\n").append(view.getContext().getString(R.string.website)).append(" : ").append(n.getSite()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(n.getPhone() != null){
|
Toast.makeText(view.getContext(), res.toString(), Toast.LENGTH_SHORT).show();
|
||||||
format += "\n" + view.getContext().getString(R.string.phone) +" : "+ n.getPhone(); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
if(n.getSite() != null){
|
|
||||||
format += "\n" + view.getContext().getString(R.string.website) +" : "+ n.getSite(); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
Toast.makeText(view.getContext(), format, Toast.LENGTH_SHORT).show();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -364,8 +372,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getPointObject(PointF point) {
|
public void collectObjectsFromPoint(PointF point, List<Object> objects) {
|
||||||
return getAmenityFromPoint(point);
|
getAmenityFromPoint(point, objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,27 +40,26 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
||||||
pointAltUI.setAntiAlias(true);
|
pointAltUI.setAntiAlias(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransportStop getFromPoint(PointF point){
|
public void getFromPoint(PointF point, List<? super TransportStop> res) {
|
||||||
TransportStop result = null;
|
|
||||||
if (objects != null) {
|
if (objects != null) {
|
||||||
int ex = (int) point.x;
|
int ex = (int) point.x;
|
||||||
int ey = (int) point.y;
|
int ey = (int) point.y;
|
||||||
int radius = getRadiusPoi(view.getZoom()) * 3 / 2;
|
int radius = getRadiusPoi(view.getZoom()) * 3 / 2;
|
||||||
|
int small = getRadiusPoi(view.getZoom());
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < objects.size(); i++) {
|
for (int i = 0; i < objects.size(); i++) {
|
||||||
TransportStop n = objects.get(i);
|
TransportStop n = objects.get(i);
|
||||||
int x = view.getRotatedMapXForPoint(n.getLocation().getLatitude(), n.getLocation().getLongitude());
|
int x = view.getRotatedMapXForPoint(n.getLocation().getLatitude(), n.getLocation().getLongitude());
|
||||||
int y = view.getRotatedMapYForPoint(n.getLocation().getLatitude(), n.getLocation().getLongitude());
|
int y = view.getRotatedMapYForPoint(n.getLocation().getLatitude(), n.getLocation().getLongitude());
|
||||||
if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {
|
if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {
|
||||||
radius = Math.max(Math.abs(x - ex), Math.abs(y - ey));
|
radius = small;
|
||||||
result = n;
|
res.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
// that's really rare case, but is much efficient than introduce synchronized block
|
// that's really rare case, but is much efficient than introduce synchronized block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,9 +68,17 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onSingleTap(PointF point) {
|
public boolean onSingleTap(PointF point) {
|
||||||
TransportStop n = getFromPoint(point);
|
ArrayList<TransportStop> stops = new ArrayList<TransportStop >();
|
||||||
if(n != null){
|
getFromPoint(point, stops);
|
||||||
Toast.makeText(view.getContext(), getStopDescription(n, true), Toast.LENGTH_LONG).show();
|
if(stops.isEmpty()){
|
||||||
|
StringBuilder res = new StringBuilder();
|
||||||
|
for (TransportStop n : stops) {
|
||||||
|
if(stops.size() > 1) {
|
||||||
|
res.append("\n");
|
||||||
|
}
|
||||||
|
res.append(getStopDescription(n, true));
|
||||||
|
}
|
||||||
|
Toast.makeText(view.getContext(), res.toString(), Toast.LENGTH_LONG).show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -172,8 +179,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getPointObject(PointF point) {
|
public void collectObjectsFromPoint(PointF point, List<Object> res) {
|
||||||
return getFromPoint(point);
|
getFromPoint(point, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,20 +1,15 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
function download {
|
function download {
|
||||||
wget -o download.log http://dumps.wikimedia.org/"$1"wiki/latest/"$1"wiki-latest-pages-articles.xml.bz2
|
echo "Start download $2";
|
||||||
|
wget --quiet --output-document="$2"_wiki_1."$1".xml.bz2 http://dumps.wikimedia.org/"$1"wiki/latest/"$1"wiki-latest-pages-articles.xml.bz2
|
||||||
}
|
}
|
||||||
# Arabic
|
cd src;
|
||||||
download ar
|
download en English;
|
||||||
# English
|
download de Deutch;
|
||||||
download en
|
download nl Netherlands;
|
||||||
# Spanish
|
download fr French;
|
||||||
download es
|
download ru Russian;
|
||||||
# Portuguese
|
download es Spanish;
|
||||||
download pt
|
download it Italian;
|
||||||
# French
|
download pt Portuguese;
|
||||||
download fr
|
download ja Japanese;
|
||||||
# German
|
|
||||||
download de
|
|
||||||
# Russian
|
|
||||||
download ru
|
|
||||||
|
|
||||||
|
|
||||||
|
|
33
build-scripts/wiki/download_coord.sh
Normal file
33
build-scripts/wiki/download_coord.sh
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
function download_coord {
|
||||||
|
|
||||||
|
echo "Start download $1"
|
||||||
|
wget --quiet --output-document="$1"wiki.sql.gz http://toolserver.org/~dispenser/dumps/coord_"$1"wiki.sql.gz
|
||||||
|
echo "Start import $1";
|
||||||
|
gunzip -c "$1"wiki.sql.gz | mysql wiki;
|
||||||
|
}
|
||||||
|
|
||||||
|
cd src_sql;
|
||||||
|
download_coord en;
|
||||||
|
download_coord de;
|
||||||
|
download_coord nl;
|
||||||
|
download_coord fr;
|
||||||
|
download_coord ru;
|
||||||
|
download_coord es;
|
||||||
|
download_coord pl;
|
||||||
|
download_coord it;
|
||||||
|
download_coord ca;
|
||||||
|
download_coord pt;
|
||||||
|
download_coord uk;
|
||||||
|
download_coord ja;
|
||||||
|
download_coord vo;
|
||||||
|
download_coord vi;
|
||||||
|
download_coord eu;
|
||||||
|
download_coord no;
|
||||||
|
download_coord da;
|
||||||
|
download_coord sv;
|
||||||
|
download_coord sr;
|
||||||
|
download_coord eo;
|
||||||
|
download_coord ro;
|
||||||
|
download_coord lt;
|
||||||
|
|
Loading…
Reference in a new issue