Update utilties

This commit is contained in:
Victor Shcherb 2015-12-02 13:45:47 +01:00
parent 23093eba7d
commit ee74636b35
3 changed files with 18 additions and 24 deletions

View file

@ -39,8 +39,9 @@ public class GeocodingUtilities {
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_FROM_CLOSEST = 1000;
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;
@ -277,7 +278,7 @@ public class GeocodingUtilities {
for (GeocodingResult street : streetsList) {
if(streetDistance == 0) {
streetDistance = street.getDistance();
} else if(street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST) {
} else if(street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST_WITH_SAME_NAME) {
continue;
}
street.connectionPoint = road.connectionPoint;

View file

@ -89,15 +89,7 @@ public class CurrentPositionHelper {
protected void justifyResult(List<GeocodingResult> res, final ResultMatcher<GeocodingResult> result) {
List<GeocodingResult> complete = new ArrayList<GeocodingUtilities.GeocodingResult>();
double minBuildingDistance = 0;
double minStreetDistance = 0;
for (GeocodingResult r : res) {
double streetDistance = r.getDistance();
if(minStreetDistance == 0) {
minStreetDistance = streetDistance;
} else if(streetDistance > GeocodingUtilities.THRESHOLD_MULTIPLIER_SKIP_STREETS_AFTER * minStreetDistance ||
streetDistance > minStreetDistance + GeocodingUtilities.DISTANCE_STREET_FROM_CLOSEST) {
break;
}
Collection<RegionAddressRepository> rar = app.getResourceManager().getAddressRepositories();
RegionAddressRepository foundRepo = null;
for(RegionAddressRepository repo : rar) {

View file

@ -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;