Merge branch 'master' of https://github.com/osmandapp/Osmand
This commit is contained in:
commit
3c86a3b38f
6 changed files with 136 additions and 80 deletions
|
@ -35,6 +35,17 @@ import org.apache.commons.logging.Log;
|
|||
public class GeocodingUtilities {
|
||||
|
||||
private static final Log log = PlatformUtil.getLog(GeocodingUtilities.class);
|
||||
|
||||
public static final float THRESHOLD_MULTIPLIER_SKIP_STREETS_AFTER = 4;
|
||||
public static final float STOP_SEARCHING_STREET_WITH_MULTIPLIER_RADIUS = 100;
|
||||
public static final float STOP_SEARCHING_STREET_WITHOUT_MULTIPLIER_RADIUS = 400;
|
||||
|
||||
public static final float DISTANCE_STREET_NAME_PROXIMITY_BY_NAME = 15000;
|
||||
public static final float DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME = 1000;
|
||||
|
||||
public static final float THRESHOLD_MULTIPLIER_SKIP_BUILDINGS_AFTER = 1.5f;
|
||||
public static final float DISTANCE_BULDING_PROXIMITY = 100;
|
||||
|
||||
public static final String[] SUFFIXES = new String[] {"av.", "avenue", "просп.", "пер.", "пр.","заул.", "проспект", "переул.", "бул.", "бульвар", "тракт"};
|
||||
public static final String[] DEFAULT_SUFFIXES = new String[] {"str.", "street", "улица", "ул."};
|
||||
private static Set<String> SET_DEF_SUFFIXES = null;
|
||||
|
@ -56,10 +67,6 @@ public class GeocodingUtilities {
|
|||
return SET_SUFFIXES;
|
||||
}
|
||||
|
||||
public static final float THRESHOLD_MULTIPLIER_SKIP_BUILDINGS_AFTER = 1.5f;
|
||||
public static final float THRESHOLD_MULTIPLIER_SKIP_STREETS_AFTER = 3;
|
||||
public static final float DISTANCE_STREET_NAME_PROXIMITY_BY_NAME = 20000;
|
||||
public static final float DISTANCE_BULDING_PROXIMITY = 100;
|
||||
public static final Comparator<GeocodingResult> DISTANCE_COMPARATOR = new Comparator<GeocodingResult>() {
|
||||
|
||||
@Override
|
||||
|
@ -138,6 +145,8 @@ public class GeocodingUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<GeocodingResult> reverseGeocodingSearch(RoutingContext ctx, double lat, double lon) throws IOException {
|
||||
RoutePlannerFrontEnd rp = new RoutePlannerFrontEnd(false);
|
||||
List<GeocodingResult> lst = new ArrayList<GeocodingUtilities.GeocodingResult>();
|
||||
|
@ -167,10 +176,11 @@ public class GeocodingUtilities {
|
|||
lst.add(sr);
|
||||
}
|
||||
}
|
||||
if(p.dist > 100*100 && dist != 0 && p.dist > 4 * dist ) {
|
||||
if(p.dist > STOP_SEARCHING_STREET_WITH_MULTIPLIER_RADIUS * STOP_SEARCHING_STREET_WITH_MULTIPLIER_RADIUS &&
|
||||
dist != 0 && p.dist > THRESHOLD_MULTIPLIER_SKIP_STREETS_AFTER * dist ) {
|
||||
break;
|
||||
}
|
||||
if(p.dist > 300*300) {
|
||||
if(p.dist > STOP_SEARCHING_STREET_WITHOUT_MULTIPLIER_RADIUS*STOP_SEARCHING_STREET_WITHOUT_MULTIPLIER_RADIUS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -212,13 +222,13 @@ public class GeocodingUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public List<GeocodingResult> justifyReverseGeocodingSearch(final GeocodingResult r, BinaryMapIndexReader reader,
|
||||
public List<GeocodingResult> justifyReverseGeocodingSearch(final GeocodingResult road, BinaryMapIndexReader reader,
|
||||
double knownMinBuidlingDistance) throws IOException {
|
||||
// test address index search
|
||||
final List<GeocodingResult> streetsList = new ArrayList<GeocodingResult>();
|
||||
final List<String> streetNamePacked = prepareStreetName(r.streetName);
|
||||
final List<String> streetNamePacked = prepareStreetName(road.streetName);
|
||||
if (streetNamePacked.size() > 0) {
|
||||
log.info("Search street by name " + r.streetName + " " + streetNamePacked);
|
||||
log.info("Search street by name " + road.streetName + " " + streetNamePacked);
|
||||
String mainWord = "";
|
||||
for(int i = 0; i < streetNamePacked.size(); i++) {
|
||||
String s = streetNamePacked.get(i);
|
||||
|
@ -235,11 +245,13 @@ public class GeocodingUtilities {
|
|||
public boolean publish(MapObject object) {
|
||||
if (object instanceof Street
|
||||
&& prepareStreetName(object.getName()).equals(streetNamePacked)) {
|
||||
double d = MapUtils.getDistance(object.getLocation(), r.searchPoint.getLatitude(),
|
||||
r.searchPoint.getLongitude());
|
||||
double d = MapUtils.getDistance(object.getLocation(), road.searchPoint.getLatitude(),
|
||||
road.searchPoint.getLongitude());
|
||||
if (d < DISTANCE_STREET_NAME_PROXIMITY_BY_NAME) {
|
||||
GeocodingResult rs = new GeocodingResult(r);
|
||||
GeocodingResult rs = new GeocodingResult(road);
|
||||
rs.street = (Street) object;
|
||||
// set connection point to sort
|
||||
rs.connectionPoint = rs.street.getLocation();
|
||||
rs.city = rs.street.getCity();
|
||||
streetsList.add(rs);
|
||||
return true;
|
||||
|
@ -259,24 +271,59 @@ public class GeocodingUtilities {
|
|||
|
||||
final List<GeocodingResult> res = new ArrayList<GeocodingResult>();
|
||||
if(streetsList.size() == 0) {
|
||||
res.add(r);
|
||||
res.add(road);
|
||||
} else {
|
||||
for (GeocodingResult s : streetsList) {
|
||||
Collections.sort(streetsList, DISTANCE_COMPARATOR);
|
||||
double streetDistance = 0;
|
||||
for (GeocodingResult street : streetsList) {
|
||||
if(streetDistance == 0) {
|
||||
streetDistance = street.getDistance();
|
||||
} else if(street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME) {
|
||||
continue;
|
||||
}
|
||||
street.connectionPoint = road.connectionPoint;
|
||||
final List<GeocodingResult> streetBuildings = loadStreetBuildings(road, reader, street);
|
||||
Collections.sort(streetBuildings, DISTANCE_COMPARATOR);
|
||||
if (streetBuildings.size() > 0) {
|
||||
Iterator<GeocodingResult> it = streetBuildings.iterator();
|
||||
if (knownMinBuidlingDistance == 0) {
|
||||
GeocodingResult firstBld = it.next();
|
||||
knownMinBuidlingDistance = firstBld.getDistance();
|
||||
res.add(firstBld);
|
||||
}
|
||||
while (it.hasNext()) {
|
||||
GeocodingResult nextBld = it.next();
|
||||
if (nextBld.getDistance() > knownMinBuidlingDistance
|
||||
* THRESHOLD_MULTIPLIER_SKIP_BUILDINGS_AFTER) {
|
||||
break;
|
||||
}
|
||||
res.add(nextBld);
|
||||
}
|
||||
}
|
||||
res.add(street);
|
||||
}
|
||||
}
|
||||
Collections.sort(res, DISTANCE_COMPARATOR);
|
||||
return res;
|
||||
}
|
||||
|
||||
private List<GeocodingResult> loadStreetBuildings(final GeocodingResult road, BinaryMapIndexReader reader,
|
||||
GeocodingResult street) throws IOException {
|
||||
final List<GeocodingResult> streetBuildings = new ArrayList<GeocodingResult>();
|
||||
reader.preloadBuildings(s.street, null);
|
||||
log.info("Preload buildings " + s.street.getName() + " " + s.city.getName() + " " + s.street.getId());
|
||||
for (Building b : s.street.getBuildings()) {
|
||||
reader.preloadBuildings(street.street, null);
|
||||
log.info("Preload buildings " + street.street.getName() + " " + street.city.getName() + " " + street.street.getId());
|
||||
for (Building b : street.street.getBuildings()) {
|
||||
if(b.getLatLon2() != null) {
|
||||
double slat = b.getLocation().getLatitude();
|
||||
double slon = b.getLocation().getLongitude();
|
||||
double tolat = b.getLatLon2().getLatitude();
|
||||
double tolon = b.getLatLon2().getLongitude();
|
||||
double coeff = MapUtils.getProjectionCoeff(r.searchPoint.getLatitude(), r.searchPoint.getLongitude(),
|
||||
double coeff = MapUtils.getProjectionCoeff(road.searchPoint.getLatitude(), road.searchPoint.getLongitude(),
|
||||
slat, slon, tolat, tolon);
|
||||
double plat = slat + (tolat - slat) * coeff;
|
||||
double plon = slon + (tolon - slon) * coeff;
|
||||
if (MapUtils.getDistance(r.searchPoint, plat, plon) < DISTANCE_BULDING_PROXIMITY) {
|
||||
GeocodingResult bld = new GeocodingResult(s);
|
||||
if (MapUtils.getDistance(road.searchPoint, plat, plon) < DISTANCE_BULDING_PROXIMITY) {
|
||||
GeocodingResult bld = new GeocodingResult(street);
|
||||
bld.building = b;
|
||||
bld.connectionPoint = b.getLocation();
|
||||
streetBuildings.add(bld);
|
||||
|
@ -301,34 +348,13 @@ public class GeocodingUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
} else if (MapUtils.getDistance(b.getLocation(), r.searchPoint) < DISTANCE_BULDING_PROXIMITY) {
|
||||
GeocodingResult bld = new GeocodingResult(s);
|
||||
} else if (MapUtils.getDistance(b.getLocation(), road.searchPoint) < DISTANCE_BULDING_PROXIMITY) {
|
||||
GeocodingResult bld = new GeocodingResult(street);
|
||||
bld.building = b;
|
||||
bld.connectionPoint = b.getLocation();
|
||||
streetBuildings.add(bld);
|
||||
}
|
||||
}
|
||||
Collections.sort(streetBuildings, DISTANCE_COMPARATOR);
|
||||
if (streetBuildings.size() > 0) {
|
||||
Iterator<GeocodingResult> it = streetBuildings.iterator();
|
||||
if (knownMinBuidlingDistance == 0) {
|
||||
GeocodingResult firstBld = it.next();
|
||||
knownMinBuidlingDistance = firstBld.getDistance();
|
||||
res.add(firstBld);
|
||||
}
|
||||
while (it.hasNext()) {
|
||||
GeocodingResult nextBld = it.next();
|
||||
if (nextBld.getDistance() > knownMinBuidlingDistance
|
||||
* THRESHOLD_MULTIPLIER_SKIP_BUILDINGS_AFTER) {
|
||||
break;
|
||||
}
|
||||
res.add(nextBld);
|
||||
}
|
||||
}
|
||||
res.add(s);
|
||||
}
|
||||
}
|
||||
Collections.sort(res, DISTANCE_COMPARATOR);
|
||||
return res;
|
||||
return streetBuildings;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2037,4 +2037,16 @@
|
|||
<string name="poi_surveillance_yes">Vigilància: sí</string>
|
||||
<string name="poi_shop_yes">Amb botiga</string>
|
||||
|
||||
<string name="poi_elevator_yes">Amb ascensor</string>
|
||||
<string name="poi_elevator_no">Sense ascensor</string>
|
||||
|
||||
<string name="poi_technical_monument">Monument tècnic</string>
|
||||
|
||||
<string name="poi_office_camping">Oficina del càmping</string>
|
||||
<string name="poi_model_aerodrome">Aeròdrom de modelisme</string>
|
||||
<string name="poi_guide">Oficina dels guies</string>
|
||||
<string name="poi_consulting">Despatx de consultors</string>
|
||||
<string name="poi_cooperative">Oficina de la cooperativa</string>
|
||||
<string name="poi_parish">Rectoria</string>
|
||||
<string name="poi_social_facility_workshop">Equipament social: taller</string>
|
||||
</resources>
|
||||
|
|
|
@ -392,7 +392,7 @@
|
|||
<string name="poi_townhall">Paço Municipal</string>
|
||||
<string name="poi_employment_agency">Agência de empregos</string>
|
||||
<string name="poi_research">Pesquisa</string>
|
||||
<string name="poi_it">TI</string>
|
||||
<string name="poi_it">Escritório de TI</string>
|
||||
<string name="poi_newspaper">Jornal</string>
|
||||
<string name="poi_architect">Arquiteto</string>
|
||||
<string name="poi_advertising_agency">Agência de publicidade</string>
|
||||
|
@ -2033,4 +2033,14 @@
|
|||
<string name="poi_escape_lane">Área de escape</string>
|
||||
|
||||
<string name="poi_crop_rice">Cultivo: arroz</string>
|
||||
<string name="poi_route_light_rail_ref">Veículo leve sobre trilhos</string>
|
||||
<string name="poi_industrial_auto_wrecker">Tipo: guincho de veículos</string>
|
||||
<string name="poi_watering_place">Balneário</string>
|
||||
<string name="poi_quango">Organização Governamental quase Autônoma</string>
|
||||
<string name="poi_office_forestry">Escritório de silvicultura</string>
|
||||
<string name="poi_logistics">Escritório de logística</string>
|
||||
<string name="poi_parish">Secretaria paroquial</string>
|
||||
<string name="poi_fuel_91ul">Combustível 91UL</string>
|
||||
<string name="poi_fuel_100ll">Combustível 100LL</string>
|
||||
<string name="poi_fuel_autogas">Autogás (GPL)</string>
|
||||
</resources>
|
||||
|
|
|
@ -2389,4 +2389,15 @@
|
|||
<string name="poi_historic_period_first_intermediate_period">歷史時期:第一中間期 (西元前2181年 - 2055年)</string>
|
||||
<string name="poi_historic_period_second_intermediate_period">歷史時期:第二中間期 (西元前1650年 - 1550年)</string>
|
||||
<string name="poi_historic_period_third_intermediate_period">"歷史時期:第三中間期 (西元前1069年 - 664年) "</string>
|
||||
<string name="poi_historic_period_first_persian_period">歷史時期:第一波斯時期</string>
|
||||
<string name="poi_historic_period_late_period">歷史時期:後期 (西元前664 - 332年)</string>
|
||||
<string name="poi_historic_period_second_persian_period">歷史時期:第二波斯時期</string>
|
||||
<string name="poi_historic_period_alexander_the_great">歷史時期:亞歷山大大帝</string>
|
||||
<string name="poi_historic_period_ptolemaic_egypt">歷史時期:托勒密埃及 (西元前305年 - 西元前30年)</string>
|
||||
<string name="poi_historic_period_christian_egypt">歷史時期:基督教埃及</string>
|
||||
<string name="poi_historic_period_byzantine_egypt">歷史時期:拜占庭埃及 (西元前30年 - 西元641年)</string>
|
||||
<string name="poi_historic_period_persian_occupation">歷史時期:波斯佔領期</string>
|
||||
<string name="poi_historic_period_greek_dark_ages">歷史時期:希臘黑暗時代 (西元前1100年 - 800年)</string>
|
||||
<string name="poi_historic_period_roman_greece">歷史時期:羅馬希臘 (西元前146年 - 西元330年)</string>
|
||||
<string name="poi_historic_period_roman_kingdom">歷史時期:羅馬王國 (西元前753年 – 西元前509年)</string>
|
||||
</resources>
|
||||
|
|
|
@ -87,13 +87,9 @@ public class CurrentPositionHelper {
|
|||
}
|
||||
|
||||
protected void justifyResult(List<GeocodingResult> res, final ResultMatcher<GeocodingResult> result) {
|
||||
double minBuildingDistance = 0;
|
||||
List<GeocodingResult> complete = new ArrayList<GeocodingUtilities.GeocodingResult>();
|
||||
double minBuildingDistance = 0;
|
||||
for (GeocodingResult r : res) {
|
||||
if (minBuildingDistance > 0
|
||||
&& r.getDistance() > GeocodingUtilities.THRESHOLD_MULTIPLIER_SKIP_STREETS_AFTER * minBuildingDistance) {
|
||||
break;
|
||||
}
|
||||
Collection<RegionAddressRepository> rar = app.getResourceManager().getAddressRepositories();
|
||||
RegionAddressRepository foundRepo = null;
|
||||
for(RegionAddressRepository repo : rar) {
|
||||
|
|
|
@ -134,7 +134,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
private DataTileManager<Recording> recordings = new DataTileManager<AudioVideoNotesPlugin.Recording>(14);
|
||||
private Map<String, Recording> recordingByFileName = new LinkedHashMap<>();
|
||||
private AudioNotesLayer audioNotesLayer;
|
||||
private MapActivity activity;
|
||||
private MapActivity mapActivity;
|
||||
private static File mediaRecFile;
|
||||
private static MediaRecorder mediaRec;
|
||||
private File lastTakingPhoto;
|
||||
|
@ -475,7 +475,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public void registerLayers(MapActivity activity) {
|
||||
this.activity = activity;
|
||||
this.mapActivity = activity;
|
||||
if (audioNotesLayer != null) {
|
||||
activity.getMapView().removeLayer(audioNotesLayer);
|
||||
}
|
||||
|
@ -718,16 +718,17 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public void mapActivityResume(MapActivity activity) {
|
||||
this.activity = activity;
|
||||
;
|
||||
this.mapActivity = activity;
|
||||
((AudioManager) activity.getSystemService(Context.AUDIO_SERVICE)).registerMediaButtonEventReceiver(
|
||||
new ComponentName(activity, MediaRemoteControlReceiver.class));
|
||||
}
|
||||
|
||||
public MapActivity getActivity() {
|
||||
return activity;
|
||||
@Override
|
||||
public void mapActivityPause(MapActivity activity) {
|
||||
this.mapActivity = null;
|
||||
}
|
||||
|
||||
|
||||
public void recordVideo(final double lat, final double lon, final MapActivity mapActivity) {
|
||||
if (AV_EXTERNAL_RECORDER.get()) {
|
||||
captureVideoExternal(lat, lon, mapActivity);
|
||||
|
@ -1035,7 +1036,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
|
||||
private void updateRecordControl(final MapActivity mapActivity, final File f) {
|
||||
recordControl.setText(app.getString(R.string.shared_string_control_stop), "");
|
||||
recordControl.setImageDrawable(activity.getResources().getDrawable(R.drawable.widget_icon_av_active));
|
||||
recordControl.setImageDrawable(mapActivity.getResources().getDrawable(R.drawable.widget_icon_av_active));
|
||||
final MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
|
||||
final boolean contains = recordControl.isVisible();
|
||||
if (!contains) {
|
||||
|
@ -1060,8 +1061,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
}
|
||||
|
||||
private void updateContextMenu(Recording rec) {
|
||||
if (activity != null) {
|
||||
MapContextMenu menu = activity.getContextMenu();
|
||||
if (mapActivity != null) {
|
||||
MapContextMenu menu = mapActivity.getContextMenu();
|
||||
if (menu.isVisible()) {
|
||||
if (rec != null) {
|
||||
menu.show(new LatLon(rec.lat, rec.lon), audioNotesLayer.getObjectName(rec), rec);
|
||||
|
@ -1196,9 +1197,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
newMap.remove(r.file.getName());
|
||||
recordingByFileName = newMap;
|
||||
Algorithms.removeAllFiles(r.file);
|
||||
if (activity != null) {
|
||||
activity.getContextMenu().close();
|
||||
activity.getMapView().refreshMap();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getContextMenu().close();
|
||||
mapActivity.getMapView().refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1217,7 +1218,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
|
||||
public boolean onMapActivityKeyEvent(KeyEvent key) {
|
||||
if (KeyEvent.KEYCODE_CAMERA == key.getKeyCode()) {
|
||||
defaultAction(activity);
|
||||
defaultAction(mapActivity);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue