OSMDroid offline maps not loading - osmdroid

Using osmdroid I am trying to build an offline mapping app.
I am using map tiles which I generated from a file server in PNG format. These are organised in the standard /x/y/z.png file/directory structure and compressed into a .zip file with the internal structure: /mapnik/x/y/z.png
The name of the .zip file is mapnik.zip (I understand the name of this file doesn't matter).
I installed my .apk by buiding it in Android Studio.
I have tried putting the .zip file in /storage/emulated/0/osmdroid and /storage/emulated/0/osmdroid/tiles which is where the cache.db and cache.db-journal files reside (this directory structure existed already).
When I run the app it runs but shows a blank grid instead of a map.
If I change map.setUseDataConnection(false); to (true) it loads the map over the internet and displays it.
Unfortunately I need this to run uniquely offline.
The code for this I got from https://github.com/TizioFittizio/OsmDroidOfflineMap
My MainActivity is as follows:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MapView map = (MapView) findViewById(R.id.map);
map.setUseDataConnection(false);
map.setTileSource(TileSourceFactory.MAPNIK);
IMapController controller = map.getController();
GeoPoint startPoint = new GeoPoint(37.370925, -5.972684);
controller.setCenter(startPoint);
Marker startMarker = new Marker(map);
startMarker.setPosition(startPoint);
startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
map.getOverlays().add(startMarker);
controller.setZoom(8);
map.setMinZoomLevel(6);
map.setMaxZoomLevel(15);
Does anybody know what I'm doing wrong?
Alternatively, has anyone else done this and did you use osmdroid? And if not, what did you use?

within your zip, it should have the following structure
/
/tileSource
/tileSource/0/0/0.png
where tile source, in your case, should be Mapnik exactly. i.e. map.setTileSource(TileSourceFactory.MAPNIK); must match the tile source name. Check out the source for TileSourceFactory to get an idea of how to create your own ITileSource. To get an idea of how the path is created, it is here.
there's also a sample dataset here which would use a tile source with the name of cb-wac
if you are still having problems,
Configuration.getInstance().setDebugMode(true));
Configuration.getInstance().setDebugTileProviders(true)); may help with debugging

Thanks to everybody who contributed. I'm totally new at Android dev so I'm grateful for people's patience.
This is working now.
My MainActivity.java is as follows:
#Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = (MapView) findViewById(R.id.map);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setUseDataConnection(false);
map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.ALWAYS);
map.setMultiTouchControls(true);
IMapController mapController = map.getController();
mapController.setZoom(13.0);
map.setMinZoomLevel(7.0);
map.setMaxZoomLevel(19.0);
map.setClickable(true);
GeoPoint startPoint = new GeoPoint(37.3691, -5.97907);
mapController.setCenter(startPoint);
My .zip file is in /storage/emulated/0/osmdroid with the structure as describe EXCEPT that the root of the .zip file is /Mapnik/ ie. case-sensitive.
I am now moving on to overlaying shape files on my map. Wish me luck!

Related

Modify Default properties on Paraview Properties Panel (5.7.0)

I try to modify the default value of a property in Paraview using a custom Plugin.
When I add a Dicom file in my pipeline, the default representation is set to "Outline" in the property panel, but I want it to be "Volume".
The goal is to interact with existing properties in Paraview
I git clone the paraview repository, and I used CMake to get the .sln file and compile it with Visual Studio. I do the same with example plugin provided by Paraview itself (like the toolbar or property widget to understand how it works), everything works for now.
But when I try to set the data representation to "volume", nothing work (no results, it still uniform.)
What i've tried (from my plugin):
pqApplicationCore* applicationCore = pqApplicationCore::instance();
pqObjectBuilder* objectBuilder = applicationCore->getObjectBuilder();
pqServerManagerModel* serverManagerModel = applicationCore->getServerManagerModel();
if (serverManagerModel->getNumberOfItems<pqServer*>() == 1)
{
// Getting the first (and only) server
pqServer* server = serverManagerModel->getItemAtIndex<pqServer*>(0);
//Creating a reader for dicom files
pqPipelineSource* pipelineSource =
objectBuilder->createReader("sources", "DICOMReader", { file }, server);
// Getting the first view
pqView* v = serverManagerModel->getItemAtIndex<pqView*>(0);
// Setting the data representation to Volume, at least, i try to set it.
pqDataRepresentation* data = objectBuilder->createDataRepresentation(
pipelineSource->getOutputPorts().at(0), v, "UniformGridRepresentation");
// SOLUTION
vtkSMPVRepresentationProxy::SetScalarColoring(data->getProxy(), "DICOMImage", vtkDataObject::POINT);
pqSMAdaptor::setEnumerationProperty(data->getProxy()->GetProperty("Representation"), "Volume");
// wrong
data->setProperty("VolumeRendering", "volume");
data->setVisible(true);
}
CMakeList.txt
set(interfaces)
set(sources
MyToolBar.cxx
MyToolBar.h
MyToolBarActions.cxx
MyToolBarActions.h)
paraview_plugin_add_action_group(…….)
paraview_plugin_add_toolbar(…..)
paraview_add_plugin(pluginName
VERSION "1.0"
UI_INTERFACES ${interfaces}
SOURCES ${sources})
target_link_libraries(cmakePluginName PRIVATE ParaView::ServerManagerRendering)
I expected the "Representation" field to be on "Volume" but still in "Outline"
I also tried to change the "UniformGridRepresentation" to something else, with no results, except weird things and crashes.
Any ideas?
The setProperty you used concern Qt property (this class inherits from QObject) and not ParaView Proxy property.
you should replace this line with the following:
edit: add the SetScalarColoring part
vtkSMPVRepresentationProxy::SetScalarColoring(data->getProxy(), <ArrayName>, vtkDataObject::POINT);
pqSMAdaptor::setEnumerationProperty(data->getProxy()->GetProperty("Representation"), "Volume");
<ArrayName> is the data you want to use for coloration. If not specified, a unique Solid Color is used but it is not available for volume rendering.
vtkDataObject::POINT can also be vtkDataObject::CELL if <ArrayName> is associated to the cells and not to the points.

opencv\modules\core\src\persistence.cpp:2697: error: (-27) NULL or empty buffer in function cvOpenFileStorage

I am trying to run a facedetection application and I get the following error:
Unexpected Standard exception from MEX file.
What() is:..\..\..\..\opencv\modules\core\src\persistence.cpp:2697: error: (-27)
NULL or empty buffer in function cvOpenFileStorage
If you're using haarcascade_frontalface_default.xml, check the xml file content.
The first 3 lines should be:
<?xml version="1.0"?>
<!--
Stump-based 24x24 discrete(?) adaboost frontal face detector.
I inadvertently downloaded the html that linked to the haarcascade_frontalface_default.xml file instead of the xml itself and got the same error you did.
You should provide some code and information.Nevertheless the error indicates that it can not access the haarcascade file. I suggest you make sure you have the "xml" in the same folder as your code (e.g. "ViewController.mm") and check permissions. additionally Assuming you are using Objective-c or swift:
1-check the file is in your Xcode project; and, if it is,
2-check it's included in the 'Copy Bundle Resources' phase underneath your selected Target (in the project tree view on the left in the normal Xcode window layout) and, if it is,
3-look inside the generated application bundle (find your product, right click, select 'Reveal in Finder', from Finder right click on the app and select 'Show Package Contents', then look for your file in there) to make sure that it's there.
I've got the same problem, and then I figure out what's the problem
First
Add file haarcascade_frontalface_default.xml to xcode project
make sure when you add the xml file with option below:
Destination: Copy items if need [check]
Added Folder: Create Folder References [check]
Add to targets: Your Project target [check]
Second
in you Wrapper.mm file add this code to your obj-c function:
const NSString* cascadePath = [[NSBundle mainBundle]pathForResource:#"haarcascade_frontalface_default" ofType:#"xml"];
or in case you wanna load the xml file, use this code:
cv::CascadeClassifier classifier;
const NSString* cascadePath = [[NSBundle mainBundle]pathForResource:#"haarcascade_frontalface_default" ofType:#"xml"];
classifier.load([cascadePath UTF8String]);
this actually fixes my problem, anywaythis question has been questioned for a long time but I hope someone face this problem can come to this answer and help them solve their problem like mine, cheer.

How to display indoor.shp file in TileMill

I make indoor map with JOSM (.osm format) then i sucessfully convert them in to shapefile(.shp format). I want to convert them in to MBTiles format in order to display andorid application by using TileMill. When i upload my shp file in TileMill project , i cant see my map. Is there a way to show it? Thank you.
Here is my .shp file link
Map {
background-color: #b8dee6;
}
#countries {
::outline {
line-color: #85c5d3;
line-width: 2;
line-join: round;
}
polygon-fill: #fff;
}
#polygon.poly {
line-color:#594;
line-width:0.5;
polygon-opacity:1;
polygon-fill:#ae8;
}
JOSM to shp to MBTiles... For an indoor map... It seems a little bit complicated.
I imagine that your map is made of lines and polygons?
I could suggest that you (re)build your indoor map from scratch as a KML file (with Google Earth, or ArcGIS, or even with Google Maps).
Then you will be able to load this KML directly on an Android device:
either with Google Earth for Android
or with OSMNavigator application (based on OSMBonusPack+osmdroid)
or by writing your own application using OSMBonusPack+osmdroid libs.

Creating a pst file using Redemption

I'm working on a project in C# that involves parsing .pst files and my group has chosen to use the Redemption library to do so. We have successfully parsed the email files in to RDOMail objects, however now we want to write a subset of those emails to a new .pst file. I have successfully written the subset to .eml files using the email.SaveAs() function, but I'm at a loss to figure out how to save that list as a .pst. I've been sifting through the documentation, however it leaves much to be desired. Can anyone who has used Redemption point me in the right direction or provide an example?? Thanks in advance for your help!
You will need to create/open a PST file using RDOSession.Stores.AddPstStore (returns RDOPSTStore object). Once you have the store, you can open/create folders (starting with the RDOStore.IPMRootFolder), create messages (RDOFolder.Items.Add) and copy old messages into new messages (RDOMail.CopyTo(RDOMail/RDOFolder)).
I have been struggling to do this for the last few hours and would like to save that time to others
You have to install redemption and add it as a reference to your project for it to work
RDOSession session = new RDOSession(); // throws exception 1
session.LogonPstStore(#"c:\temp\output.pst");
RDOFolder folder = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox);
string[] fileEntries = Directory.GetFiles(#"C:\emlFiles\", "*.eml");
foreach (string filePath in fileEntries)
{
RDOMail mail = folder.Items.Add("IPM.Mail");
mail.Sent = true;
mail.Import(filePath, 1024);
// folder.Items.Add(mail);
mail.Save();
}
session.Logoff();
I also created a small sample windows forms app for it, I know the code is ugly but it does the trick

Getting an incorrect permissions screen in the webview Blackberry 10 Cascades Beta 3 SDK in Dev Alpha Simulator

I am trying to make dynamically generated html 5 graphs show up in a webview in Blackberry 10 Cascades. I have confirmed the html5 that I have generated, draws the correct graphs. My problem is that when I try to implement this in the Blackberry 10 Cascades Beta 3 SDK (using the Blackberry 10 Dev Alpha Simulator), the webview that is supposed to show the graph, just looks like this:
Here is the code that leads to this error:
//html_ already contains the html-5 code to make the graph at this point in the code
//This is the file path to a local file that is actually accessable in the emulator
//and not just from Windows
//
QFile *chartFile = new QFile("app/native/assets/data/chart.html");
if (chartFile->open(QIODevice::WriteOnly)) {
chartFile->write(html_.toUtf8());
chartFile->flush();
chartFile->close();
}
if (chartFile) delete chartFile;
if (graphView_) {
graphView_->setHtml("");
graphView_->setUrl(QUrl::fromLocalFile("app/native/assets/data/chart.html"));
}
I checked the permissions of that file, put they are all Allow (777 permissions for those who know Unix style permissions).
I added access_internet to the bar-descriptor.xml, eventhough my app was already able to access remote sites, just to see if that would fix it, but it did not.
I've been searching around trying to find a solution to this problem, but I have not.
If anyone could help me out with this, it would be greatly appreciated.
-------------------------------------------------------
Update:
I changed the code to set the html directly, now I have this:
if (graphView_) {
graphView_->setHtml(html_, QUrl("app/native/assets/data/chart.html"));
}
But nothing shows. It seems I have the wrong relative path relative to my base url.
My base url is this: QUrl("app/native/assets/data/chart.html")
My relative paths all begin with: ./Highcharts/js/...
My relative paths are located under: app/native/assets/data/Highcharts/js
It seems to me that I this should work, but when I do this, I just a blank screen, as if it can not find my relative paths. So I don't know what's going on here either.
I found a solution that works. I'm using the first approach, not the updated approach, but instead of
graphView_->setUrl(QUrl("app/native/assets/data/chart.html"));
I'm using:
graphView_->setUrl(QUrl("local:///assets/data/chart.html"));
And I have left the rest of the code the same, and it works.