Register  |  Login
ThinkGeo - GPS Tracking and Mapping Solutions  |  Home  |  Cygnus Track  |   Code Community

Discussion Forums

The online community for users of Map Suite GIS components

RSS Feed Available AddThis - Bookmarking and Sharing Button Printer Friendly

PrevPrev NextNext

Map Suite Vehicle Tracking Starter Kit QuickStart Guide

Posted by ThinkGeo on 01-29-2010 12:40 PM

This QuickStart Guide will show you how you can use the Map Suite Vehicle Tracking Starter Kit to easily develop a Web-based vehicle tracking project with ThinkGeo's Map Suite Web Edition. Please note that in order to follow the examples below, you will need to have installed Map Suite Web Edition 3.0 or higher (either the free evaluation or full licensed version).

Welcome to the Map Suite Vehicle Tracking Starter Kit from ThinkGeo®. This QuickStart Guide will show you how you can use the Starter Kit to easily develop a Web-based vehicle tracking project with ThinkGeo's Map Suite Web Edition. Using the intuitive object model, even developers inexperienced in Geographic Information Systems (GIS) can have a fully functional vehicle tracking application working in minutes.

When you open the Vehicle Tracking Starter Kit solution with Visual Studio, you are presented with four projects.

Introduction of the Four Projects

We have included two main implementations of vehicle tracking. One is a Server implementation, which uses server-side events and an Update Panel, while the other implementation is an AJAX version, which uses Callback technology. Each implementation is offered in both a C# and a VB.NET project, making for a total of four projects. The functionality is exactly the same between these four projects but the implementation methodology is totally different.

Server implementation: Almost all of the functionality is implemented by using server-side events so that you can easily understand what the events are doing and so that you can easily debug with Visual Studio. However, please note that some client states are not disposed of by the Update Panel, so that when running this application for a long time there may be memory leaks on the client side.

AJAX implementation: Almost all of the functionality is implemented by using client-side JavaScript. As such, we don't need to postback to the server side every time; instead, we use Callback technology to minimize the need to transfer data over the Internet, which enhances the user experience.

Screenshot

Overview of Vehicle Tracking

Screenshot

1) Vehicle Information

Screenshot

"Robert":

Name of the vehicle driver.

"In Motion":

Current vehicle's status. It is "Idle" when the vehicle is motionless for 4 minutes.

"Date":

Date and time at which the vehicle was most recently tracked.

"Area":

Indicates whether the vehicle is inside of a spatial fence or not. In this sample, we have defined a spatial fence as a warning district. If any vehicle enters the warning district, it shows a warning here such as:

Screenshot

"Speed":

Current vehicle speed.

"Duration":

The time, in minutes, that the vehicle has been traveling at the same speed.

2) Auto Refresh

Click this button to simulate loading data from GPS on the fly. This will make the vehicle move and update the vehicle information as well.

Screenshot

3) Pan Button

Screenshot

Click this button to navigate the map by using tools such as panning, mouse wheel zooming and track zoom in.

4) Draw Spatial Fence

Click the "Draw Fence" button to open the following dialog.

Screenshot

Icon

Click this button to draw a new spatial fence on the map.

Icon

Click this button to edit existing spatial fences.

Icon

Click this button to save the spatial fences to the database.
It's not enabled until you click either the track spatial fence button or the edit button.

Icon

Click this button to delete the selected spatial fences from the map. It's not enabled until you click the edit button.

5) Measure Tool

Screenshot

Click this button to activate the measurement function on the map. When this function is activated, you can click on the map to begin drawing a polyline (a line with one or more segments). Each additional click will begin drawing a new segment of the same line. You can double-click to finish drawing the polyline. When you do, a bubble displaying the total length of the line will appear on the map.

Screenshot

Using SQL Server Instead of Access

It is easy to transfer this project from using a Microsoft Access Database to using Microsoft SQL Server instead. In the Vehicle Tracking Starter Kit’s installation folder, there is a subfolder called App_Data that contains a file named VehicleTrackingDb.mdf.

Screenshot

Attach this data file to your SQL Server; three tables will be generated automatically.

Screenshot

Next, modify the connection string for SQL Server in the web.config file. Here is an example:

<connectionStrings>
    <add name="VehicleTrackingDbConnectionString" connectionString="Data Source=[ServerName];Initial Catalog=[DatabaseName];Persist Security Info=True;User ID=[UserName];Password=[Password]" />
</connectionStrings>

Now you have successfully configured the environment to use SQL Server. As a next step, you need to make a few changes within the project code. Let’s take the CSWebAjaxSample project for example; to begin, please open VehicleTracking.aspx.cs. You may notice that this file contains many comments that have been written to help you easily understand this application and how it works. In the code, you will find a data provider whose type is "TrackingAccessProvider"; in addition, there will be a commented-out snippet of code above it. It should look like this:

// using (TrackingSqlProvider dataProvider = new TrackingSqlProvider(ConfigurationManager.ConnectionStrings["VehicleTrackingDbConnectionString"].ConnectionString))
//
using (TrackingAccessProvider dataProvider = new TrackingAccessProvider(MapPath(ConfigurationManager.AppSettings["AccessDataBase"])))

This object is responsible for all of the communication with the database. To switch from using the Access provider to the SQL Server provider, uncomment the line that begins "using (TrackingSqlProvider", then comment-out the line that begins "using (TrackingAccessProvider". Do this everywhere this code occurs in the VehicleTracking.aspx.cs file. Once you have made these changes, press F5 to run the application and verify that its connection to your SQL Server is working properly.

Summary

Now you know the basic functionality of the Map Suite Vehicle Tracking Starter Kit. Please enjoy experimenting with this project and learning from the code and our comments therein. We hope the sample code provided in this Starter Kit will help guide you in the right direction toward implementing a higher performance vehicle tracking application with Map Suite Web Edition.

If you have questions about anything covered in this QuickStart Guide, the ThinkGeo Support Team is ready and available to help. Please post your questions or comments below, or start a new topic in the Vehicle Tracking Starter Kit official support forum.



8 Comments

ekoUser is Offline
06-19-2010 03:55 AM
Avatar
dear support

We have a plan to buy whole sets of Vehicle tracking starter Kit and MApSeuite Web edition. can you advise the table structure (table field)


JohnnyUser is Offline
06-21-2010 03:30 AM
Avatar

eko,

Please have a look at the attached sql script about VehicleTracking data base.

thanks,

Johnny

ekoUser is Offline
06-22-2010 11:02 AM
Avatar
Johnny
great thanks!
Since our requirements might be different can we change the table fields and just making change at the code?
also my understanding is that the geofences will be created by putting one coordinates and specified the radius from that point so the geofences will be like a circular.
but with your system the geofence will be on free form (rectangular,circular,etc)

is the FenceGeometry field will be in GPS coordinate form , ex: 1.234E 0.123W something like that?

CREATE TABLE [dbo].[SpatialFence](
[ID] [smallint] IDENTITY(1,1) NOT NULL,
[FenceGeometry] [varchar](1024) NULL,
[FeatureID] [text] NULL

please advise soonest. thanks


ekoUser is Offline
06-22-2010 11:08 AM
Avatar
Johnny
in our project we will make a over speed alerts based on road segments (every road segments will have different speed limit). is that applicable on the system?
basically, whether with the vehicle tracking starter kit we can modified the tables so its suitable with our application?


DavidUser is Offline
06-22-2010 11:07 PM
Avatar
Eko,

I can help you with some of these questions..

1. The geofences are free form and we store them as a polygon. They are very flexible and you can add your own fences to the table. We store the polygons as Well Known Text, see link below. The coordinates are in decimal degrees which is what your GPS returns. The only difference is that it is not in Degrees, Minutes and Seconds but just a decimal number for the X & Y.

http://en.wikipedia.org/wiki/Well-known_text

2. If you know the speed limit for each segment you can modify the code to fit your requirements. There are a few ways to accomplish what you want and I will outline one of them. You would create a new table that would have the Feature Id of the road as the primary key and then another field which would be the speed limit. On the server side when we draw the location of the vehicle we will do a spatial query against the road data to find the road that is nearest to the vehicles location. We get the road's Feature Id and query the speed table. We then compare the vehicles speed to the table and determine if they are speeding.

Having said that it is better that if you want a more formal system I suggest you create a Windows Service that queries the database every 30 seconds or one minute and gets the current location of the vehicle and does the same logic. The reason for a service is that it will run even if no one is logged onto the system. The service could send e-mails etc about violations to the alerts. The service would not be hard to write and would use most of the code some the vehicle tracking kit. The kit was designed to be all on the server side in ASP.NET and a starting point but in a final production installation I suggest you move the alert logic to a service.

David


ekoUser is Offline
06-23-2010 12:39 PM
Avatar
David and Jonny
thank you very much for the reply. FYI, we are on the final decision to purchase the product.
Last questions. since the overspeed alert will happen onboard (at GPS tracking device on truck using x86 embedded controller) we will use SQL Compact 3.5. the overspeed alert then send to server using SQL RDA/Merge replication system.
Is the SQL compact 3.5 support WKT? is it will need a conversion? please explain in detail


ekoUser is Offline
06-23-2010 01:23 PM
Avatar
other question
can we use geography data for geofence instead geometry? just in case if SQL CE 3.5 not support


DavidUser is Offline
06-23-2010 10:55 PM
Avatar
Eko,

I want to make sure I understand you setup. For your onboard device that uses the embedded controller will that use Windows CE or regular Windows?

The way we store the WKT as a string means we are not taking advantage of SQL's built in geographic or geometric APIs. We are simply storing the text and then we read from the table just as normal and then us our own math to check of the point is in the polygon. Of course we could store the data as geographic or geometric using the SQL Spatial API and then you could use a query to find that out. The reason we went with test and storing the data in plain WKT is that we wanted to support databases such as Access, or other ones that do not have any spatial features.

The reason I asked if you use Windows CE is that if you do then you may need to use the NTS Compact framework, a free component, that will allow you to do geometric functions in Windows CE. You can use that to work with WKT and check if the point is in the polygon for spatial fences.

For speeding alerts do you plan to place all of the road data on-board your GPS tracking device?

David


You are not authorized to post a reply.
Active Forums 4.2