Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Osm geo changes #259

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ local.properties
/build

/build
com_crashlytics_export_strings.xml
com_crashlytics_export_strings.xml

*/generatedLibs/*.aar
*/generatedLibs/*.jar
Binary file not shown.
102 changes: 90 additions & 12 deletions OSMBonusPack/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,59 @@
apply plugin: 'com.android.library'

//set version name here
def libVersionName = "6.0-SNAPSHOT"

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 26
buildToolsVersion "26.0.2"

defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 60
versionName "6.0-SNAPSHOT"
minSdkVersion 14
targetSdkVersion 25
versionCode 61
versionName libVersionName
//adds version to .aar file
setProperty("archivesBaseName", "${archivesBaseName}-$versionName")
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

lintOptions{
disable 'MissingTranslation'
}
}

//for use of aar files as libs
repositories {
jcenter()
flatDir {
dirs 'aarLibs'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])

compile "com.android.support:support-v4:23.1.1"
compile 'org.osmdroid:osmdroid-android:5.5:release@aar'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
// implementation(name:'osmdroid-android-5.5-release', ext:'aar')
// implementation ('org.osmdroid:osmdroid-android-5.5-release@aar'){
// transitive=true
// }

implementation "com.android.support:support-v4:26.1.0"
implementation 'org.osmdroid:osmdroid-android:5.5:release@aar'
implementation 'org.apache.commons:commons-lang3:3.3.2'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.squareup.okhttp3:okhttp:3.7.0'

// implementation project(":OSMBonusPack")

implementation 'org.osmdroid:osmdroid-mapsforge:5.5:release@aar'
implementation 'org.mapsforge:mapsforge-map-android:0.6.1'
implementation 'org.mapsforge:mapsforge-map:0.6.1'
}

apply from: '../maven.gradle'
Expand All @@ -36,3 +63,54 @@ install {
pom.version = "6.0-SNAPSHOT"
}
}



//to generate sources after Build > Build APK
afterEvaluate {
assembleDebug.doLast {
logger.warn('--- assembleDebug copy libs to generatedLibs')
copySourcesAar.execute()
sourcesJar.execute()
copySourcesJar.execute()
}
assembleRelease.doLast {
logger.warn('--- assembleRelease copy libs to generatedLibs')
copySourcesAar.execute()
sourcesJar.execute()
copySourcesJar.execute()
}
}

//task to generate java doc, Gradle -> Tasks -> Other -> sourcesJar > run(double click)
//sources will be in build\libs\*-sources.jar
task sourcesJar(type: Jar) {
logger.warn('---START sourcesJar')
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
logger.warn('---END sourcesJar')
}

task copySourcesJar(type: Copy){
//versionName
def fromDir = ("$buildDir/libs")
def toDir = rootProject.file('OSMBonusPack/generatedLibs')
from fromDir
into toDir
include('**/*.jar', '**/*.aar') //exclude ('**/*unsigned.apk', '**/*unaligned.apk')

logger.warn('--- copyJAR fromDir:'+fromDir+' toDir:'+toDir)
}
copySourcesJar.dependsOn sourcesJar
copySourcesJar.mustRunAfter sourcesJar

task copySourcesAar(name: 'copySourcesAar', type: Copy){
def fromDir = ("$buildDir/outputs/aar")
// def fromDir = rootProject.file('widgetsmodule/src/test');
def toDir = rootProject.file('OSMBonusPack/generatedLibs')
from fromDir
into toDir
include('**/*.aar', '**/*.jar')

logger.warn('--- copyAAR fromDir:'+fromDir+' toDir:'+toDir)
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public void setGridSize(int gridSize){
//Log.d("ZOOM", "zoomlevel="+mapView.getZoomLevel()+" cells="+numCellsW);
//Log.d("ZOOM", "gridSizeX="+gridSizeX+" gridSizeY="+gridSizeY);

ArrayList<StaticCluster> clusters = new ArrayList<StaticCluster>();
LongSparseArray<StaticCluster> sparseArray = new LongSparseArray<StaticCluster>();
ArrayList<StaticCluster> clusters = new ArrayList<>();
LongSparseArray<StaticCluster> sparseArray = new LongSparseArray<>();
for (Marker item:mItems){
//TODO - add 180° to prevent negative values
long gridX = (long)(item.getPosition().getLongitude() / gridSizeX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public abstract class MarkerClusterer extends Overlay {
/** impossible value for zoom level, to force clustering */
protected static final int FORCE_CLUSTERING = -1;

protected ArrayList<Marker> mItems = new ArrayList<Marker>();
protected ArrayList<Marker> mItems = new ArrayList<>();
protected Point mPoint = new Point();
protected ArrayList<StaticCluster> mClusters = new ArrayList<StaticCluster>();
protected ArrayList<StaticCluster> mClusters = new ArrayList<>();
protected int mLastZoomLevel;
protected Bitmap mClusterIcon;
protected String mName, mDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public void setMaxClusteringZoomLevel(int zoom){
/** Radius-Based clustering algorithm */
@Override public ArrayList<StaticCluster> clusterer(MapView mapView) {

ArrayList<StaticCluster> clusters = new ArrayList<StaticCluster>();
ArrayList<StaticCluster> clusters = new ArrayList<>();
convertRadiusToMeters(mapView);

mClonedMarkers = new ArrayList<Marker>(mItems); //shallow copy
mClonedMarkers = new ArrayList<>(mItems); //shallow copy
while (!mClonedMarkers.isEmpty()) {
Marker m = mClonedMarkers.get(0);
StaticCluster cluster = createCluster(m, mapView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author M.Kergall
*/
public class StaticCluster {
protected final ArrayList<Marker> mItems = new ArrayList<Marker>();
protected final ArrayList<Marker> mItems = new ArrayList<>();
protected GeoPoint mCenter;
protected Marker mMarker;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class KmlDocument implements Parcelable {

/** default constructor, with the kmlRoot as an empty Folder */
public KmlDocument(){
mStyles = new HashMap<String, StyleSelector>();
mStyles = new HashMap<>();
mMaxStyleId = 0;
mKmlRoot = new KmlFolder();
mLocalFile = null;
Expand Down Expand Up @@ -159,7 +159,7 @@ protected static GeoPoint parseKmlCoord(String input){

/** KML coordinates are: lon,lat{,alt} tuples separated by separators (space, tab, cr). */
protected static ArrayList<GeoPoint> parseKmlCoordinates(String input){
LinkedList<GeoPoint> tmpCoords = new LinkedList<GeoPoint>();
LinkedList<GeoPoint> tmpCoords = new LinkedList<>();
int i = 0;
int tupleStart = 0;
int length = input.length();
Expand Down Expand Up @@ -188,7 +188,7 @@ protected static ArrayList<GeoPoint> parseKmlCoordinates(String input){
}
i++;
}
ArrayList<GeoPoint> coordinates = new ArrayList<GeoPoint>(tmpCoords.size());
ArrayList<GeoPoint> coordinates = new ArrayList<>(tmpCoords.size());
coordinates.addAll(tmpCoords);
return coordinates;
}
Expand All @@ -200,21 +200,22 @@ protected static ArrayList<GeoPoint> parseKmlCoordinates(String input){
* @param url
* @return true if OK, false if any error.
*/
public boolean parseKMLUrl(String url){
Log.d(BonusPackHelper.LOG_TAG, "KmlProvider.parseKMLUrl:"+url);
HttpConnection connection = new HttpConnection();
connection.doGet(url);
InputStream stream = connection.getStream();
boolean ok;
if (stream == null){
ok = false;
} else {
ok = parseKMLStream(stream, null);
}
connection.close();
//Log.d(BonusPackHelper.LOG_TAG, "KmlProvider.parseKMLUrl - end");
return ok;
}
public boolean parseKMLUrl(String url) {
Log.d(BonusPackHelper.LOG_TAG, "KmlProvider.parseKMLUrl:" + url);
HttpConnection connection = new HttpConnection();
try {
connection.doGet(url);
} catch (Exception e) {
e.printStackTrace();
return false;
}
InputStream stream = connection.getStream();
boolean ok;
ok = stream != null && parseKMLStream(stream, null);
connection.close();
//Log.d(BonusPackHelper.LOG_TAG, "KmlProvider.parseKMLUrl - end");
return ok;
}

/**
* Get the default path for KML file on Android: on the external storage, in a "kml" directory.
Expand Down Expand Up @@ -341,9 +342,9 @@ public KmlSaxHandler(File file, ZipFile kmzContainer){
mFile = file;
mKMZFile = kmzContainer;
mKmlRoot = new KmlFolder();
mKmlFeatureStack = new ArrayList<KmlFeature>();
mKmlFeatureStack = new ArrayList<>();
mKmlFeatureStack.add(mKmlRoot);
mKmlGeometryStack = new ArrayList<KmlGeometry>();
mKmlGeometryStack = new ArrayList<>();
mIsNetworkLink = false;
mIsInnerBoundary = false;
}
Expand Down Expand Up @@ -503,7 +504,7 @@ else if (name.equals("GroundOverlay"))
} else { //inside a Polygon innerBoundaryIs element: new hole
KmlPolygon polygon = (KmlPolygon) mKmlCurrentGeometry;
if (polygon.mHoles == null)
polygon.mHoles = new ArrayList<ArrayList<GeoPoint>>();
polygon.mHoles = new ArrayList<>();
ArrayList<GeoPoint> hole = parseKmlCoordinates(mStringBuilder.toString());
polygon.mHoles.add(hole);
}
Expand Down Expand Up @@ -771,7 +772,7 @@ public KmlDocument(Parcel in){
mKmlRoot = in.readParcelable(KmlFeature.class.getClassLoader());
//mStyles = in.readHashMap(Style.class.getClassLoader());
int size = in.readInt();
mStyles = new HashMap<String, StyleSelector>(size);
mStyles = new HashMap<>(size);
for(int i=0; i<size; i++){
String key = in.readString();
Style value = in.readParcelable(Style.class.getClassLoader());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,12 @@ public KmlFeature(){
* @param C KmlGeometry subclass to compare
* @return true if this a KML Placemark containing a KML Geometry of class C.
*/
public boolean hasGeometry(Class<? extends KmlGeometry> C){
if (!(this instanceof KmlPlacemark))
return false;
KmlPlacemark placemark = (KmlPlacemark)this;
KmlGeometry geometry = placemark.mGeometry;
if (geometry == null)
return false;
return C.isInstance(geometry);
}
public boolean hasGeometry(Class<? extends KmlGeometry> C) {
if (!(this instanceof KmlPlacemark)) return false;
KmlPlacemark placemark = (KmlPlacemark) this;
KmlGeometry geometry = placemark.mGeometry;
return geometry != null && C.isInstance(geometry);
}

/**
* @param name
Expand Down Expand Up @@ -153,7 +150,7 @@ public String getExtendedDataAsText(){
*/
public void setExtendedData(String name, String value){
if (mExtendedData == null)
mExtendedData = new HashMap<String,String>();
mExtendedData = new HashMap<>();
mExtendedData.put(name, value);
}

Expand Down Expand Up @@ -251,7 +248,7 @@ public KmlFeature clone(){
return null;
}
if (mExtendedData != null){
kmlFeature.mExtendedData = new HashMap<String,String>(mExtendedData.size());
kmlFeature.mExtendedData = new HashMap<>(mExtendedData.size());
kmlFeature.mExtendedData.putAll(mExtendedData);
}
return kmlFeature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class KmlFolder extends KmlFeature implements Cloneable, Parcelable {

public KmlFolder(){
super();
mItems = new ArrayList<KmlFeature>();
mItems = new ArrayList<>();
}

public KmlFolder(FolderOverlay overlay, KmlDocument kmlDoc){
Expand Down Expand Up @@ -227,7 +227,7 @@ public JsonObject geoJSONNamedCRS(String crsName){
public KmlFolder clone(){
KmlFolder kmlFolder = (KmlFolder)super.clone();
if (mItems != null){
kmlFolder.mItems = new ArrayList<KmlFeature>(mItems.size());
kmlFolder.mItems = new ArrayList<>(mItems.size());
for (KmlFeature item:mItems)
kmlFolder.mItems.add(item.clone());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static JsonArray geoJSONCoordinates(ArrayList<GeoPoint> coordinates){
}

public static ArrayList<GeoPoint> cloneArrayOfGeoPoint(ArrayList<GeoPoint> coords){
ArrayList<GeoPoint> result = new ArrayList<GeoPoint>(coords.size());
ArrayList<GeoPoint> result = new ArrayList<>(coords.size());
for (GeoPoint p:coords)
result.add(p.clone());
return result;
Expand All @@ -111,7 +111,7 @@ public static GeoPoint parseGeoJSONPosition(JsonArray json){
public static ArrayList<GeoPoint> parseGeoJSONPositions(JsonArray json){
if (json == null)
return null;
ArrayList<GeoPoint> coordinates = new ArrayList<GeoPoint>(json.size());
ArrayList<GeoPoint> coordinates = new ArrayList<>(json.size());
for (int i=0; i<json.size(); i++){
JsonArray position = json.get(i).getAsJsonArray();
GeoPoint p = KmlGeometry.parseGeoJSONPosition(position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public KmlGroundOverlay(GroundOverlay overlay){
GeoPoint pS = p.destinationPoint(overlay.getHeight()/2, 180.0f);
GeoPoint pE = p.destinationPoint(overlay.getWidth()/2, 90.0f);
GeoPoint pW = p.destinationPoint(overlay.getWidth()/2, -90.0f);
mCoordinates = new ArrayList<GeoPoint>(2);
mCoordinates = new ArrayList<>(2);
mCoordinates.add(new GeoPoint(pN.getLatitude(), pW.getLongitude())); //NW
mCoordinates.add(new GeoPoint(pS.getLatitude(), pE.getLongitude())); //SE
//mIconHref = ???
Expand Down Expand Up @@ -98,7 +98,7 @@ public void setIcon(String href, File containerFile, ZipFile kmzContainer){
}

public void setLatLonBox(double north, double south, double east, double west){
mCoordinates = new ArrayList<GeoPoint>(2);
mCoordinates = new ArrayList<>(2);
mCoordinates.add(new GeoPoint(north, west));
mCoordinates.add(new GeoPoint(south, east));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class KmlMultiGeometry extends KmlGeometry implements Cloneable, Parcelab

public KmlMultiGeometry(){
super();
mItems = new ArrayList<KmlGeometry>();
mItems = new ArrayList<>();
}

/** GeoJSON constructor */
Expand Down Expand Up @@ -110,7 +110,7 @@ public void addItem(KmlGeometry item){

@Override public KmlMultiGeometry clone(){
KmlMultiGeometry kmlMultiGeometry = (KmlMultiGeometry)super.clone();
kmlMultiGeometry.mItems = new ArrayList<KmlGeometry>(mItems.size());
kmlMultiGeometry.mItems = new ArrayList<>(mItems.size());
for (KmlGeometry item:mItems)
kmlMultiGeometry.mItems.add(item.clone());
return kmlMultiGeometry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public KmlPoint(JsonObject json){

public void setPosition(GeoPoint position){
if (mCoordinates == null){
mCoordinates = new ArrayList<GeoPoint>(1);
mCoordinates = new ArrayList<>(1);
mCoordinates.add(position);
} else
mCoordinates.set(0, position);
Expand Down
Loading