├── .gitignore~
├── .gitignore
├── lint.xml
├── libs
├── jts-1.12.jar
├── armeabi
│ └── libjsqlite.so
└── spatialite-android-library.jar
├── res
├── drawable-hdpi
│ └── icon.png
├── drawable-ldpi
│ └── icon.png
├── drawable-mdpi
│ ├── file.png
│ ├── folder.png
│ └── icon.png
├── values
│ └── strings.xml
└── layout
│ ├── canvas.xml
│ ├── listview_item.xml
│ └── main.xml
├── gen
└── com
│ └── spatialite
│ ├── BuildConfig.java
│ └── R.java
├── META-INF
└── MANIFEST.MF
├── src
└── com
│ └── spatialite
│ ├── MessageType.java
│ ├── QueryDataThread.java
│ ├── TestActivity.java
│ └── MapCanvas.java
├── local.properties
├── .classpath
├── project.properties
├── .settings
└── org.eclipse.jdt.core.prefs
├── README.md
├── proguard-project.txt
├── AndroidManifest.xml
├── proguard.cfg
└── .project
/.gitignore~:
--------------------------------------------------------------------------------
1 | bin/
2 |
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | tags
3 |
4 |
--------------------------------------------------------------------------------
/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/libs/jts-1.12.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shiyj/AndroidGIS/HEAD/libs/jts-1.12.jar
--------------------------------------------------------------------------------
/libs/armeabi/libjsqlite.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shiyj/AndroidGIS/HEAD/libs/armeabi/libjsqlite.so
--------------------------------------------------------------------------------
/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shiyj/AndroidGIS/HEAD/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shiyj/AndroidGIS/HEAD/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shiyj/AndroidGIS/HEAD/res/drawable-mdpi/file.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shiyj/AndroidGIS/HEAD/res/drawable-mdpi/folder.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shiyj/AndroidGIS/HEAD/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/libs/spatialite-android-library.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shiyj/AndroidGIS/HEAD/libs/spatialite-android-library.jar
--------------------------------------------------------------------------------
/gen/com/spatialite/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.spatialite;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: TestActivity
4 | Bundle-SymbolicName: TestActivity
5 | Bundle-Version: 1.0.0.qualifier
6 | Export-Package: com.spatialite
7 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello Giser, This is a demo from GeoInker!
4 | GeoInker
5 | Load the last datasource
6 |
7 |
--------------------------------------------------------------------------------
/src/com/spatialite/MessageType.java:
--------------------------------------------------------------------------------
1 | package com.spatialite;
2 |
3 | public class MessageType {
4 | public static final int SEND_LENGTH = 0;
5 | public static final int SEND_ENVELOPE = 1;
6 | public static final int SEND_PROGRESS = 2;
7 | public static final int SEND_GEOMETRIES = 3;
8 | public static final int SEND_ERR = 9;
9 | }
10 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 |
7 | # location of the SDK. This is only used by Ant
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=/home/engin/appstore/android-sdk-linux
11 |
--------------------------------------------------------------------------------
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-8
15 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.6
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.6
12 |
--------------------------------------------------------------------------------
/res/layout/canvas.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/res/layout/listview_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
13 |
21 |
--------------------------------------------------------------------------------
/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Android GIS
2 |
3 | ## App introduction:
4 |
5 |
6 | This is a native GIS plantform made for Android.
7 |
8 | This application is based on [spatialite-android](http://code.google.com/p/spatialite-android/).
9 | But as you known,spatialite-android just is a geodatabase library, how can we show the data in view? The purpose of this app is to solve it.
10 |
11 | ## Installation
12 |
13 | Just import it into eclipse and then run.
14 |
15 | **Note:** *I have compiled the source code of spatialite-android and got two file "/libs/armeabi/libjsqlite.so" and "/libs/spatialite-android-library.jar" ,and then I copy them into this project.*
16 |
17 |
18 | ## useage
19 | Perhaps you nead a sample database, download it [here](http://geoinker.com/file/test.sqlite).Then use this application to open it.
20 |
21 |
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
21 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembernames class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembernames class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers enum * {
30 | public static **[] values();
31 | public static ** valueOf(java.lang.String);
32 | }
33 |
34 | -keep class * implements android.os.Parcelable {
35 | public static final android.os.Parcelable$Creator *;
36 | }
37 |
--------------------------------------------------------------------------------
/gen/com/spatialite/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.spatialite;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class drawable {
14 | public static final int file=0x7f020000;
15 | public static final int folder=0x7f020001;
16 | public static final int icon=0x7f020002;
17 | }
18 | public static final class id {
19 | public static final int ItemName=0x7f050004;
20 | public static final int fileTypeIcon=0x7f050003;
21 | public static final int imageView1=0x7f050002;
22 | public static final int listView1=0x7f050006;
23 | public static final int loadLast=0x7f050005;
24 | public static final int zoom_in=0x7f050000;
25 | public static final int zoom_out=0x7f050001;
26 | }
27 | public static final class layout {
28 | public static final int canvas=0x7f030000;
29 | public static final int listview_item=0x7f030001;
30 | public static final int main=0x7f030002;
31 | }
32 | public static final class string {
33 | public static final int app_name=0x7f040001;
34 | public static final int hello=0x7f040000;
35 | public static final int load_last=0x7f040002;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | spatialite
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
30 | full,incremental,
31 |
32 |
33 |
34 |
35 | org.eclipse.pde.ManifestBuilder
36 |
37 |
38 |
39 |
40 | org.eclipse.pde.SchemaBuilder
41 |
42 |
43 |
44 |
45 |
46 | com.android.ide.eclipse.adt.AndroidNature
47 | org.eclipse.jdt.core.javanature
48 | org.eclipse.cdt.core.cnature
49 | org.eclipse.cdt.core.ccnature
50 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
51 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
52 | org.eclipse.pde.PluginNature
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/com/spatialite/QueryDataThread.java:
--------------------------------------------------------------------------------
1 | package com.spatialite;
2 |
3 | import java.util.ArrayList;
4 |
5 | import jsqlite.Exception;
6 | import jsqlite.Stmt;
7 | import com.spatialite.MessageType;
8 |
9 | import android.app.ProgressDialog;
10 | import android.os.Handler;
11 | import android.os.Message;
12 | import android.util.Log;
13 |
14 | import com.vividsolutions.jts.geom.Envelope;
15 | import com.vividsolutions.jts.geom.Geometry;
16 | import com.vividsolutions.jts.index.strtree.STRtree;
17 | import com.vividsolutions.jts.io.ParseException;
18 | import com.vividsolutions.jts.io.WKBReader;
19 |
20 | public class QueryDataThread extends Thread {
21 |
22 | private final jsqlite.Database mDatabase;
23 | private Handler mHandler;
24 | private String mTableName;
25 |
26 | public QueryDataThread(jsqlite.Database database, Handler handler) {
27 | mDatabase = database;
28 | mHandler = handler;
29 | }
30 |
31 | public void setTableName(String tableName) {
32 | this.mTableName = tableName;
33 | }
34 |
35 | @Override
36 | public void run() {
37 | Message mMsg = mHandler.obtainMessage();
38 | if (null == mTableName) {
39 | mMsg.obj = "You must set the table name before you run the query thread!";
40 | mMsg.what = MessageType.SEND_ERR;
41 | mMsg.sendToTarget();
42 | return;
43 | }
44 | try {
45 | // checking the Vector Layers
46 | String getExtendSQL = "SELECT row_count, ";
47 | getExtendSQL += "extent_min_x, extent_min_y, ";
48 | getExtendSQL += "extent_max_x, extent_max_y ";
49 | getExtendSQL += "FROM layer_statistics ";
50 | getExtendSQL += "WHERE table_name = '";
51 | getExtendSQL += mTableName + "'";
52 |
53 | Stmt extStmt = mDatabase.prepare(getExtendSQL);
54 | getExtendSQL = null;
55 | if (extStmt.step()) {
56 | int layer_length = extStmt.column_int(0);
57 | mMsg.obj = layer_length;
58 | mMsg.what = MessageType.SEND_LENGTH;
59 | mMsg.sendToTarget();
60 | double[] env = new double[4];
61 | env[0] = extStmt.column_double(1);
62 | env[1] = extStmt.column_double(2);
63 | env[2] = extStmt.column_double(3);
64 | env[3] = extStmt.column_double(4);
65 | mMsg = mHandler.obtainMessage();
66 | mMsg.obj = env;
67 | env = null;
68 | mMsg.what = MessageType.SEND_ENVELOPE;
69 | mMsg.sendToTarget();
70 | }
71 |
72 | // Create query
73 | String query = "SELECT AsBinary(geometry) from ";
74 | query += mTableName;
75 | // String query =
76 | // "SELECT name, AsBinary(geometry) from HighWays limit 100";
77 | // String query = "SELECT name, AsBinary(geometry) from Regions";
78 | Stmt stmt = mDatabase.prepare(query);
79 | query = null;
80 | // ArrayList geoms = new ArrayList();
81 | // get the fist geometry type as the who geometry type;
82 | Log.w("查询", "开始查询时间……");
83 | int i = 0;
84 | WKBReader wkbReader = new WKBReader();
85 | STRtree indexRtree = new STRtree();
86 | while (stmt.step()) {
87 | // Create JTS geometry from binary representation
88 | // returned from database
89 | try {
90 | // geoms.add(wkbReader.read(stmt.column_bytes(1)));
91 | Geometry geometry = wkbReader.read(stmt.column_bytes(0));
92 | indexRtree.insert(geometry.getEnvelopeInternal(), geometry);
93 | geometry = null;
94 | mMsg = mHandler.obtainMessage();
95 | mMsg.obj = i++;
96 | mMsg.what = MessageType.SEND_PROGRESS;
97 | mMsg.sendToTarget();
98 | } catch (ParseException e) {
99 | Log.e("ERR!!!", e.getMessage());
100 | }
101 | }
102 | wkbReader = null;
103 | Log.w("查询", "结束查询,开始转换……");
104 | stmt.close();
105 | stmt = null;
106 | mMsg = mHandler.obtainMessage();
107 | mMsg.obj = indexRtree;
108 | mMsg.what = MessageType.SEND_GEOMETRIES;
109 | indexRtree = null;
110 | mMsg.sendToTarget();
111 | } catch (Exception e) {
112 | // Log.e("ERR!!!", e.getMessage());
113 | mMsg = mHandler.obtainMessage();
114 | mMsg.obj = e.getMessage();
115 | mMsg.what = MessageType.SEND_ERR;
116 | mMsg.sendToTarget();
117 | }
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/src/com/spatialite/TestActivity.java:
--------------------------------------------------------------------------------
1 | package com.spatialite;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.FileNotFoundException;
7 | import java.io.FileOutputStream;
8 | import java.io.IOException;
9 | import java.util.ArrayList;
10 | import java.util.HashMap;
11 | import java.util.List;
12 | import java.util.Map;
13 |
14 | import android.app.Activity;
15 | import android.app.AlertDialog;
16 | import android.app.AlertDialog.Builder;
17 | import android.content.Context;
18 | import android.content.Intent;
19 | import android.os.Bundle;
20 | import android.view.View;
21 | import android.widget.AdapterView;
22 | import android.widget.Button;
23 | import android.widget.ListView;
24 | import android.widget.SimpleAdapter;
25 | import android.widget.Toast;
26 | import android.widget.AdapterView.OnItemClickListener;
27 |
28 | public class TestActivity extends Activity {
29 | private String cacheFileName = "geoinker_db_dir.gik";
30 | private String currentDirString = "";
31 | private File currentFileParent;
32 | private File[] currentFiles;
33 | private ListView list;
34 | Context context;
35 |
36 | private void geoinkerInit() {
37 | currentFileParent = new File("/mnt/sdcard/");
38 | if (!currentFileParent.exists()) {
39 | AlertDialog.Builder exitApp = new Builder(this);
40 | exitApp.setTitle("No SDCard!");
41 | exitApp.setMessage("No SDCard are detected!");
42 | return;
43 | }
44 | File dir1 = new File("/mnt/sdcard/GeoInker");
45 | mkdatadir(dir1);
46 | File dir2 = new File("/mnt/sdcard/GeoInker/database");
47 | mkdatadir(dir2);
48 | File dir3 = new File("/mnt/sdcard/GeoInker/shp");
49 | mkdatadir(dir3);
50 | currentFileParent = dir1;
51 | currentFiles = currentFileParent.listFiles();
52 | inflateListView(currentFiles);
53 | currentDirString = readLastDir();
54 | if (null == currentDirString) {
55 | Button bt = (Button) findViewById(R.id.loadLast);
56 | bt.setEnabled(false);
57 | }
58 |
59 | }
60 |
61 | private void mkdatadir(File dir) {
62 | if (!dir.exists()) {
63 | dir.mkdir();
64 | }
65 | }
66 |
67 | @Override
68 | protected void onCreate(Bundle savedInstanceState) {
69 | super.onCreate(savedInstanceState);
70 | context = this;
71 | setContentView(R.layout.main);
72 |
73 | list = (ListView) findViewById(R.id.listView1);
74 | // binding the click listener of each file item in the listview
75 | list.setOnItemClickListener(new OnItemClickListener() {
76 | @Override
77 | public void onItemClick(AdapterView> adapterView, View view,
78 | int position, long id) {
79 | //the first one is a button switch to parent file
80 | if (0 == position) {
81 | currentFileParent = currentFileParent.getParentFile();
82 | if (null == currentFileParent) {
83 | Toast.makeText(TestActivity.this,
84 | "This is the root directory!", Toast.LENGTH_LONG)
85 | .show();
86 | return;
87 | }
88 | currentFiles = currentFileParent.listFiles();
89 | inflateListView(currentFiles);
90 | return;
91 | }
92 | position = position - 1;
93 | if (currentFiles[position].isFile()) {
94 | openDataSource(currentFiles[position].getPath());
95 | return;
96 | }
97 |
98 | File[] tem = currentFiles[position].listFiles();
99 | if (tem == null || tem.length == 0) {
100 |
101 | Toast.makeText(TestActivity.this,
102 | "No File in this directory", Toast.LENGTH_LONG)
103 | .show();
104 | } else {
105 | currentFileParent = currentFiles[position];
106 | currentFiles = tem;
107 | inflateListView(currentFiles);
108 | }
109 |
110 | }
111 | });
112 |
113 | geoinkerInit();
114 | }
115 |
116 | @Override
117 | protected void onActivityResult(int requestCode, int resultCode, Intent data)
118 | {
119 | switch (resultCode)
120 | {
121 | //return if the canvas can't get data from database
122 | case RESULT_OK:
123 | //get the error message from bundle
124 | Bundle bl= data.getExtras();
125 | String errString=bl.getString("err");
126 | AlertDialog.Builder errOpenDB = new Builder(context);
127 | errOpenDB.setTitle("Can't open the data!");
128 | errOpenDB.setMessage(errString);
129 | errOpenDB.setPositiveButton("OK", null);
130 | errOpenDB.create().show();
131 | break;
132 | default:
133 | break;
134 | }
135 | }
136 |
137 | private void openDataSource(String path){
138 | Intent intent = new Intent(TestActivity.this, MapCanvas.class);
139 | Bundle dataSource = new Bundle();
140 | dataSource.putString("datasource", path);
141 | intent.putExtras(dataSource);
142 | startActivityForResult(intent, 0);
143 | }
144 | public void onClick(View v) {
145 | if (v.getId() == R.id.loadLast) {
146 |
147 | }
148 | }
149 |
150 | /**
151 | * @param files
152 | * the currend directory files. flate the list view with the
153 | * currend directory file
154 | */
155 | private void inflateListView(File[] files) {
156 | List