Real time location tracking - windows program or browser based?
I want to track a few hundred, maybe a few thousand people in real time.
Let's say that the hardware aspects are sorted out and I can get the data into a database.
Now, I want to get it out and show it, in real-time.
Weeeell ... "real-enough" time. Let's say that I want to draw a floorplan 开发者_开发问答of a building and plot everyone every 1 to 5 seconds.
(I might want to show only certain "kinds" of people at the click of a button; I will need datamining, etc, but let's stick with the worse case scenario).
I am comfortable enough with PHP, though not this sort of thing. I personally would be happier with a windows app coded in Delphi, but the trend seems to be to make everything browser based.
So, the question, I guess is whether a browser can handle this and whether there are compelling arguments for a windows-based or browser-based solution.
If browser-based can handle this (displaying a few thousand data-points a second), and there are no overwhelming arguments for windows then I guess I will go for browser-based and learn a few new tricks. The obvious advantage being that I could also re-use a large part of my code for (vehicle) tracking on Google maps.
Most of your work will probably be done in your spatially enabled relational database. For example, PostGIS can select data points within a bounding box or more sophisticated spatial predicates (ST_Contains, ST_Crosses, ST_Intersects, ST_Touches, ...) as well as the usual SQL joins and WHERE conditions. Spatial selects should use a spatial index to speed things up.
If this is the case, your app will largely be a presentation layer. In this case, use whatever will be easiest for you. The advantage of browser-based is that it is cross-platform client-server by default, but this might not matter to you.
With respect to render speed, it really depends on how you are planning to render your map. There are speed tests available for Google Maps. However, I suspect that if you are planning on a google maps type interface several thousand points are going to turn into a blur of pins. Do you have an interface mockup?
If you'd be happier with one type of app versus another, then write that type of app. Don't make something a browser app just to make it a browser app.
First you should understand what is the target of your app (and its size, how many concurrent clients?), and then decide if a fat client or a thin/web one suits it best. Then you should check which kind of application is able to manage the load you forecast. Could you display a few thousand datapoint every second or so with the technology you master or can in your timeframe? Would multithreading help you to exploit current multicore processors to achieve your result? Which technology will let you take advantage of it?
Maybe seems a bit old hat, but if you do decide to go browser based, you could pre-render the points to an image and just show the image?
WebSockets
Take a look at HTML5 WebSockets, they are a new standard for server/browser data exchange:
WebSockets is a technology providing for bi-directional, full-duplex communications channels, over a single Transmission Control Protocol (TCP) socket, designed to be implemented in web browsers and web servers.
The server can push new data to the client when it becomes available, removing the overhead of client pull requests.
The Wikipedia page lists available server-side implementations, including PHP versions (but not Delphi).
WebSockets are not bound to JavaScript, the websockets.org page says:
In addition, the Web Socket protocol can be used to support a diverse set of clients (e.g. JavaScript, Adobe Flex, JavaFX, Microsoft Silverlight, etc.). However, the HTML5 specification only defines support for JavaScript, which is limited to text-based protocols. To serve other client-types and support binary protocols you will need to look to external offerings.
Message data can be exchanged in JSON format, which is supported by JavaScript and also available for Delphi (as open source implementations like SuperObject or lkJSON).
Ajax
Ajax based rich internet applications for Delphi can be built using Intraweb or ExtPascal. ExtPascal is an Object Pascal (Delphi, FreePascal/Lazarus) wrapper/binding for Ext JS, a complete GUI Ajax framework and offers transparent support for all main web browsers: IE 6+, Firefox 1.5+, Safari 3+, Opera 9+ and Chrome 2+ on any client side platform (PCs, SmartPhones, iPhone, PDAs, etc). Online demo applications: FishFacts, more.
Ajax Push (aka Reverse Ajax / Comet) offers "HTTP server push" of data (in XML or JSON format) which transfers data from the server to all connected web browser clients whenever data on the server changes. Clients can 'subscribe' to the information they are interested in.
精彩评论