Using OpenStreetMap data in an offline C# webforms application - c#

As part of a project, I have to develop a offline C# application that can calculate the distance and journey time between two points. I'm planning on using data from OpenStreetMap but I'm not too sure what the process would involve. I do not want to use OSM's API but rather develop my own backend, to ensure continuity in case someone else decides to pick up the project to improve it. I have several questions:
Where do I download a full map of the United Kingdom from the website?
How would I overlay the postcodes, addresses, places of interests onto the map?
How would this information be read by the C# application (i.e. when the user enters point A or B, it should be pulled from a central database and automatically calculate the distance and journey time between both)
I want the information to be stored on the client side, without the need for a server - is this possible?

Please ask only one question at a time.
Question 1: OSM offers various ways for downloading data. In your case you should download a country extract.
Question 2: For displaying a map either use raster tiles or vector tiles. But before that you should decide whether you want to render your own tiles (in which case you will need some kind of tile server) or use available tiles from the web (in which case you will need constant access to the web).
Question 3: Ideally your C# application will just query a local PostgreSQL/PostGIS database.
Question 4: Which information? Everything? That would require lots of resources on the client for storing and querying the data.

Related

Creation of a graphical interface to save and view historical logged data

Im working with a 3rd party system where lots of settings are saved. These are typically single numbers, but in some cases can take the form of 1D or 2D tables. Within this system there is no versioning, backup, or history for the settings. Once you change a number you cannot revert your change, or look back what the number was 2 weeks ago. I am creating something to handle this.
The data could be described like this:
Var_A = {1}
Var_B = {3.4}
Table_A = {2,4.5,3,10}
Table_B = {{2,5,7}{3,8,1}{2,65,106}}
I have a simple c# console app where I am able to pull data from this system via a websocket interface and can display data in real time in the console, or write to a simple .txt log file. With a seperate app I can also send values back to the 3rd party system.
What I would like to acheive:
Save all values from the 3rd party system on demand to some sort of log/database
View historical values - A simple interface where I can jump through time and look back at historical values. Veiwing each complete timestep is fine for a first step, but an ultimate aim would be to be able to drill down into the history of invividual values, and be able to search for when certain values changed.
Send values back to the 3rd party system - both individual values and the entire record from any given 'save' time
All of this should be easy to deploy on a series of windows PCs without lots of external dependancies
What I need help with:
What should I look at to save the values? At most there will be in the order of several hundred 'saves' of around 50 variables per deployment - Not high frequency data. Can I use something like an .xml file? do I need a database, and if so what should I be considering with a priority on lightweight and easy to deploy?
What librarys and projects are out there to get me started on the historical data gui? Im sure what im trying to acheive has parallels elsewhere and someone out there has already done a far better job of this than I will starting completely from scratch. Im open to all options at this stage - wpf/winforms, browser based, or other. Im most comfortable with C# and the .net world and my existing code to import and export data is C# but I'm open to picking up other options if theres a really good solution elsewhere I can leverage.

Hosting my own Google Analytics solution

I want to collect, store et report tracking datas (like used features, clicked buttons, ...) using javascript library and .net API. I know Google Analytics will be perfect for this. But my direction doesn't want to use it for privacy and security reasons. So i have to develop one or use an all-in-one package (piwik maybe).
Do you have any tips for me ?
Thanks
You could use ID's these are allowed to use as long as google cannot identify the user behind it, so a system which uses the id's in GA to obtain more information about a user can be very useful solution.
Since your direction does not want to use GA you could create it yourself.
It has been done at my company for certain situations.
I will not do your homework but the concept of it is :
Send calls to a homemade webservice (json format is pretty good for this),
create the service so it can interpret the json and put the raw data in a temporary Database. Do data checks , merges with backend data and possible conversions and store everything in a database from where you will make your reports.

GMap.NET + C# + postgreSQL without Internet connection

I have a desktop app in C# using GMap.NET and it's great, but my app must work without Internet. I thought, I needed kinda PostgreSQLProvider for GMap.NET.
So I downloaded an .osm file for Russian Federation, created a postgresql database with postGIS extention and then executed query, which was generated with osm2po (it's huge: 1,2 Gb)
Now I have a databese, which can be visualized with QGis. I want to visualize this database map in my C# application to handle user mouse button clicks and draw some objects on map.
How can I do that? Maybe I should use another framework? All I need from map is get placemarks in mouse button click handler function and draw objects on map.
You can prefetch the maps you want with the demo version of GMAP.NET. Then grab the database generated by the prefetch and use it in your application. its located in
C:\Users\USERNAME\AppData\Local\GMap.NET\TileDBv5\en\Data.gmdb
the Database is in SQLite but I figure you can convert it to any DBMS you want.
I found, where the problem in. osm2po generate for me vector map, but GMap visualize only raster. The solution is to use another framework, such as SharpMap, that can work with vector maps from database.
Of course, I can write my own PgSQLProvider for GMap, but I have only a month and still many other works.

Accessing different Bing Map Layers

Is there a part of the api for access different map layer data such as population heat maps, county boundaries or zipcode lines?
I know this is mostly handled by people like ESRI/ArcServer but I was curious is there was some way to get similar information on the phone platform.
At this point, the only way i see it, is to have a huge data set, parse it, and draw the polygons myself. This sounds extremely time consuming on a phone.
Sadly Google, Bing Maps et al. don't expose access to their datasets in anything other than the pre-defined road, satellite styles etc. As tghamm suggests, your best bet for a performant solution on a mobile device is not to draw dynamic polygons, but pre-render your own raster tilesets for the area/zoom levels at which you want to display the data and display these as a custom tile layer ontop of the map control.
A good toolchain for creating such a tileset is:
1.) Use SQL Server Express (or PostGIS, if you prefer) as backend spatial DB - http://www.microsoft.com/express/sql/ ($0)
2.) Get necessary data in shapefile format - http://www.diva-gis.org/Data ($0)
3.) Load the shapefile data into SQL Server - http://www.sharpgis.net/page/shape2sql.aspx ($0)
4.) Write a query to retrieve the necessary information from SQL Server (or retrieve it directly from shapefile) and render it to tiles using Mapnik - http://www.mapnik.org ($0)
Total cost, $0.
Also, be sure to check out open street map - http://osm.org, which provide access to their entire database that you can download and render yourself - in many areas of the world (although not all) it beats both Google and Microsoft in quality and completeness of its data.
Often this data is delivered through use of a tile server, where the geometries are rendered on a server and then cut into tiles so that the client is only responsible for consuming the raster data. There's plenty of places to get good imagery:
http://www.census.gov/geo/www/tiger/
This is a good starting point for your basic geo-political shapes in the US.
From there, there are third party libraries capable of assisting you with consumption of those SHP files directly, such as http://www.thinkgeo.com/.
Alternatively, some people choose to upload the contents of the shp file into a db structure that supports spatial types. I've used Sql Server 2008, which is complimented by some .Net libraries to facilitate shape handling and manipulation for rendering.
Finally, there are likely a good number of open tile servers out there with useful data layers that you need only understand the tiling pattern to consume, e.g. WMS.

C# App database - small, miltiple-form application - forms need to exchange data via database

To give you some background, the project I am working on is a poker tournament manager. It uses two forms - the main form will display information throughout the tournament, such as players remaining, player names, stakes, payout structure, time left etc; and the other form will be used as a 'setup' form. Both of these forms are built and working, but I am struggling to get them to share data with each other.
What I want to do is load the setup form, select my options for configuring the tournament, and then clicking 'save' will assign all of my options to variables and then write these variables to a database of some kind (I'm new to DB design and I haven't used any DB objects in Visual Studio yet). The main form can then read the DB and display the relevant data. The benefits I can see of this is that the tournament setup can be saved for future use, and player stats can be accumulated over time.
What sort of database object do I need to create to store this data, and how do I open connections etc and write data to the DB?
I'd probably suggest that you use LINQ to SQL. ScottGu did an excellent series on blog posts on how to build a model with this. You only really need to read the first few for a simple CRUD application.
http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx
http://weblogs.asp.net/scottgu/archive/2007/05/29/linq-to-sql-part-2-defining-our-data-model-classes.aspx
http://weblogs.asp.net/scottgu/archive/2007/06/29/linq-to-sql-part-3-querying-our-database.aspx
http://weblogs.asp.net/scottgu/archive/2007/07/11/linq-to-sql-part-4-updating-our-database.aspx
http://weblogs.asp.net/scottgu/archive/2007/07/16/linq-to-sql-part-5-binding-ui-using-the-asp-linqdatasource-control.aspx
http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx
http://weblogs.asp.net/scottgu/archive/2007/08/23/linq-to-sql-part-7-updating-our-database-using-stored-procedures.aspx
http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executing-custom-sql-expressions.aspx
http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource-gt-control.aspx
Reference: http://msdn.microsoft.com/en-us/library/bb425822.aspx

Categories

Resources