Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88c980c
commit e40ca7a
Showing
65 changed files
with
3,383 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
OpenStreetMapViewer/src/main/java/org/osmdroid/samplefragments/data/SampleShapeFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package org.osmdroid.samplefragments.data; | ||
|
||
import android.os.Build; | ||
import android.view.Menu; | ||
import android.view.MenuInflater; | ||
import android.view.MenuItem; | ||
|
||
import com.github.angads25.filepicker.controller.DialogSelectionListener; | ||
import com.github.angads25.filepicker.model.DialogConfigs; | ||
import com.github.angads25.filepicker.model.DialogProperties; | ||
import com.github.angads25.filepicker.view.FilePickerDialog; | ||
|
||
import org.osmdroid.samplefragments.BaseSampleFragment; | ||
import org.osmdroid.shape.ShapeConverter; | ||
import org.osmdroid.tileprovider.modules.ArchiveFileFactory; | ||
import org.osmdroid.views.overlay.FolderOverlay; | ||
|
||
import java.io.File; | ||
import java.util.Set; | ||
|
||
/** | ||
* created on 1/28/2018. | ||
* | ||
* @author Alex O'Ree | ||
*/ | ||
|
||
public class SampleShapeFile extends BaseSampleFragment { | ||
@Override | ||
public String getSampleTitle() { | ||
return "Shape File Import"; | ||
} | ||
final int MENU_ADD_SHAPE= Menu.FIRST; | ||
|
||
@Override | ||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { | ||
menu.add(0, MENU_ADD_SHAPE, Menu.NONE, "Import a shape file"); | ||
super.onCreateOptionsMenu(menu, inflater); | ||
} | ||
|
||
@Override | ||
public void onPrepareOptionsMenu(Menu menu) { | ||
|
||
super.onPrepareOptionsMenu(menu); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()) { | ||
case MENU_ADD_SHAPE: | ||
showPicker(); | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
private void showPicker() { | ||
DialogProperties properties = new DialogProperties(); | ||
properties.selection_mode = DialogConfigs.SINGLE_MODE; | ||
properties.selection_type = DialogConfigs.FILE_SELECT; | ||
properties.root = new File(DialogConfigs.DEFAULT_DIR); | ||
properties.error_dir = new File(DialogConfigs.DEFAULT_DIR); | ||
properties.offset = new File(DialogConfigs.DEFAULT_DIR); | ||
|
||
Set<String> registeredExtensions = ArchiveFileFactory.getRegisteredExtensions(); | ||
registeredExtensions.add("shp"); | ||
|
||
|
||
String[] ret = new String[registeredExtensions.size()]; | ||
ret = registeredExtensions.toArray(ret); | ||
properties.extensions = ret; | ||
|
||
FilePickerDialog dialog = new FilePickerDialog(getContext(), properties); | ||
dialog.setTitle("Select a File"); | ||
dialog.setDialogSelectionListener(new DialogSelectionListener() { | ||
@Override | ||
public void onSelectedFilePaths(String[] files) { | ||
//files is the array of the paths of files selected by the Application User. | ||
try { | ||
FolderOverlay folder = ShapeConverter.convert(mMapView, new File(files[0])); | ||
mMapView.getOverlayManager().add(folder); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
|
||
}); | ||
dialog.show(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
description = 'Shapefile support for osmdroid' | ||
|
||
apply plugin: 'com.android.library' | ||
apply from: "https://raw.githubusercontent.com/gradle-fury/gradle-fury/v1.1.4/gradle/android-support.gradle" | ||
|
||
android { | ||
|
||
} | ||
|
||
dependencies { | ||
|
||
testCompile 'junit:junit:4.12' | ||
compile project(':osmdroid-android') | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Originally sourced from https://sourceforge.net/projects/javashapefilere/ by Author: olenus | ||
License: ASF 2.0 | ||
|
||
For sample Shapefiles, try this | ||
http://thematicmapping.org/downloads/TM_WORLD_BORDERS_SIMPL-0.3.zip | ||
|
||
See also https://github.com/osmdroid/osmdroid/issues/906 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="org.osmdroid.shape" > | ||
|
||
|
||
</manifest> |
Oops, something went wrong.