Scale bar: allow extend unit adapters

This commit is contained in:
Emux
2019-08-27 15:00:26 +03:00
parent 5779d10632
commit 83aed13683
3 changed files with 13 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org * Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2016 devemux86 * Copyright 2016-2019 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,17 +15,13 @@
*/ */
package org.oscim.scalebar; package org.oscim.scalebar;
public final class ImperialUnitAdapter implements DistanceUnitAdapter { public class ImperialUnitAdapter implements DistanceUnitAdapter {
public static final ImperialUnitAdapter INSTANCE = new ImperialUnitAdapter(); public static final ImperialUnitAdapter INSTANCE = new ImperialUnitAdapter();
private static final double METER_FOOT_RATIO = 0.3048; public static final double METER_FOOT_RATIO = 0.3048;
private static final int ONE_MILE = 5280; public static final int ONE_MILE = 5280;
private static final int[] SCALE_BAR_VALUES = {26400000, 10560000, 5280000, 2640000, 1056000, 528000, 264000, public static final int[] SCALE_BAR_VALUES = {26400000, 10560000, 5280000, 2640000, 1056000, 528000, 264000,
105600, 52800, 26400, 10560, 5280, 2000, 1000, 500, 200, 100, 50, 20, 10, 5, 2, 1}; 105600, 52800, 26400, 10560, 5280, 2000, 1000, 500, 200, 100, 50, 20, 10, 5, 2, 1};
private ImperialUnitAdapter() {
// do nothing
}
@Override @Override
public double getMeterRatio() { public double getMeterRatio() {
return METER_FOOT_RATIO; return METER_FOOT_RATIO;

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org * Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2016 devemux86 * Copyright 2016-2019 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,16 +15,12 @@
*/ */
package org.oscim.scalebar; package org.oscim.scalebar;
public final class MetricUnitAdapter implements DistanceUnitAdapter { public class MetricUnitAdapter implements DistanceUnitAdapter {
public static final MetricUnitAdapter INSTANCE = new MetricUnitAdapter(); public static final MetricUnitAdapter INSTANCE = new MetricUnitAdapter();
private static final int ONE_KILOMETER = 1000; public static final int ONE_KILOMETER = 1000;
private static final int[] SCALE_BAR_VALUES = {10000000, 5000000, 2000000, 1000000, 500000, 200000, 100000, 50000, public static final int[] SCALE_BAR_VALUES = {10000000, 5000000, 2000000, 1000000, 500000, 200000, 100000, 50000,
20000, 10000, 5000, 2000, 1000, 500, 200, 100, 50, 20, 10, 5, 2, 1}; 20000, 10000, 5000, 2000, 1000, 500, 200, 100, 50, 20, 10, 5, 2, 1};
private MetricUnitAdapter() {
// do nothing
}
@Override @Override
public double getMeterRatio() { public double getMeterRatio() {
return 1; return 1;

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2014 Christian Pesch * Copyright 2014 Christian Pesch
* Copyright 2014-2016 devemux86 * Copyright 2014-2019 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,16 +15,12 @@
*/ */
package org.oscim.scalebar; package org.oscim.scalebar;
public final class NauticalUnitAdapter implements DistanceUnitAdapter { public class NauticalUnitAdapter implements DistanceUnitAdapter {
public static final NauticalUnitAdapter INSTANCE = new NauticalUnitAdapter(); public static final NauticalUnitAdapter INSTANCE = new NauticalUnitAdapter();
private static final int ONE_MILE = 1852; public static final int ONE_MILE = 1852;
private static final int[] SCALE_BAR_VALUES = {9260000, 3704000, 1852000, 926000, 370400, 185200, 92600, public static final int[] SCALE_BAR_VALUES = {9260000, 3704000, 1852000, 926000, 370400, 185200, 92600,
37040, 18520, 9260, 3704, 1852, 926, 500, 200, 100, 50, 20, 10, 5, 2, 1}; 37040, 18520, 9260, 3704, 1852, 926, 500, 200, 100, 50, 20, 10, 5, 2, 1};
private NauticalUnitAdapter() {
// do nothing
}
@Override @Override
public double getMeterRatio() { public double getMeterRatio() {
return 1; return 1;