is there any library that is able to read parse a .shp file, preferably on where I don't need to use NDK.
I was trying to use GeoTools but i can't seam to get it to work on Android.
I've been using two lightweight shapefile parsers with good results in Android: diewald_shapeFileReader and Java ESRI Shape File Reader.
GeoTools relies heavily on AWT and Java Service Provider Interface (SPI) both not supported by Android. So it´s not a viable option.
EDIT 2021
Osmdroid library as of Mar 24st, 2019, Release: 6.1.0,
supports overlaying shapefiles using the Java ESRI Shape File Reader I mentioned previously.
Syntax:
List<Overlay> folder = ShapeConverter.convert(mMapView, new File(myshape));
mMapView.getOverlayManager().addAll(folder);
mMapView.invalidate();
Where
myshape is a .shp file somewhere on the drive. If other metadata files
are found, they will be used and injected into the converted shapes.
Related
Recently I saw it is possible to include assets in the Android Library with the update on November 2018 on the Official documentation here:
https://developer.android.com/studio/projects/android-library
But it just describes briefly that "assets" is an optional library that could be included in the Android libraries. It does not cover the way how to access them.
Right now I have a project with several Android libraries. Each library contains a level or it is contained on a level of abstraction. In order to have good isolation, ideally each library should be able to use the code and assets which is contained by its own Android library.
So, my question is, since now we can include assets, in my case a json file, inside of the Android library, is there any way to access those assets directly from the code of the Android library itself, without using the code from the app library?
Thanks in advance
P.d.: Here is the source code of my project if anyone is interested:
https://github.com/jiahaoliuliu/chutoro/tree/feature/companiesList
Looks like you want to use the AssetManager.
After importing
import android.content.res.AssetManager;
and initializing it
AssetManager assetManager = getAssets();
you can load assets by using
InputStream input = assetManager.open("PersistentDestinations.json");
Please note that you have to convert the InputStream in order to pass it to e.g. a JSONObject. (e.g. see here)
Read & Write shapefiles in android or java
How can i read and write shapefiles in Android or java?
.shp .shx and etc
i much searched but nothing
I want read file and edit information and write in same file or new file.
This is important i can write to file. i can read file but this isn't my problem
Thanks
Take Gdal for Android for a try.
Gdal
A translator library for raster and vector geospatial data formats that is released under an X/MIT style Open Source license by the Open Source Geospatial Foundation. As a library, it presents a single raster abstract data model and single vector abstract data model to the calling application for all supported formats. It also comes with a variety of useful command line utilities for data translation and processing. The NEWS page describes the January 2017 GDAL/OGR 2.1.3 release.
Read/Write API Tutorial
Building for Android on Linux
Either, Google for pre-compiled package
I'm developing an offline routing application for android.
I'm working with osmdroid library. and I downloaded the pbf file for the region where I want to do the offline navigation but I'm not sure how to be able to convert the binary representation of the maps in the pbf files into a normal text.
You don't have to use the PBF format, at the moment the OSM XML format is still widely in use. But if you do, then you will probably have to implement a PBF reader for Android. See osmosis which serves as the reference implementation for PBF and can also convert between those two file formats.
You can take a look at the Android page in the OSM wiki where lots of OSM-related Android application are listed. Maybe there is already an Android application supporting PBF. But most of them will just display tiles and the rather popular OsmAnd uses its own file format instead.
Note that PBF has various advantages compared to XML. It is smaller and it is faster to read and write than compressed XML. It also supports random access which can become very handy for a routing engine.
I am able to read the xls document but I don't know how to display it in my application. Do anyone have idea how to display MS Document files using apache poi library?
I have tried searching on google, everywhere only how to read document is mentioned not how to display these document. I don't want to modify the data inside document,Just want to display it.
Thanks in advance
The Apache POI library does not display documents in Android. It is for reading and writing those files, not displaying them. Quoting the mission statement:
The Apache POI Project's mission is to create and maintain Java APIs for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft's OLE 2 Compound Document format (OLE2). In short, you can read and write MS Excel files using Java. In addition, you can read and write MS Word and MS PowerPoint files using Java. Apache POI is your Java Excel solution (for Excel 97-2008). We have a complete API for porting other OOXML and OLE2 formats and welcome others to participate.
I am currently trying to import an offline map to nutiteq.
I have downloaded a map from OpenStreetMap but that map has an .osm extension.
How can I import that kind of extension to Android ?
As scai mentions, .osm is raw data file which cannot be directly used. .osm is data exchange format and it needs processing to be used in applications, including apps with Nutiteq SDK. Main missing piece from .osm file is visual styling: .osm file defines coordinates of objects and identity (e.g. that a line is "highway"), but it gives no hint whatsoever how to draw it - with which colors, line width etc.
What I'd suggest to try is to convert .osm file to .map file using osmosis, and then use mapsforge library to render a map like shown in Nutiteq wiki page. Mapsforge includes some default style, but you can find nicer stylesheets. There are several providers for readymade and up-to-date .map files with OpenStreetMap data, so maybe you do not need to do the conversion, one of them is AndroidMaps who even includes even several stylesheets.
.osm is just OSM's XML file format containing elements and tags. That is, it contains raw data. According to the nutiteq website nutiteq doesn't support this format directly. But it supports various other formats like MBTiles which are suitable for offline use.