views:

278

answers:

5

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.

+1  A: 

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.

Amber
+1 and I sort of agree. I could get it done more quickly as a windows app, but 1) I get to learn something new 2) if it's browser based it is easier to use google maps (I know that I can embed a browser in a windows program and do it that way) and 3) the clincher is that more potential customers are asking for browser-based.
Mawg
+3  A: 

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?

fmark
+1 wish it could be more!! I didn't even know that there was a "spatially enabled relational database"!Browser-based or not?? 80% of potential customers (most of them the large ones) are closed-shop windows installations. Browser means MSIE only. But they see a benefit in browser-based as they don't have to install an app on every PC.
Mawg
Most modern RDBMS have a spatial extension now. Postgresql has PostGIS (my personal favourite), Oracle has Oracle spatial (the original), mysql v5 has it built in, MS SQL 2008 also has it built in, even sqlite has spatialite!
fmark
btw, the main question is probably whether there might be problems displaying a few thousand items every second in the browser ...
Mawg
There will be if you use google maps. See my edit above.
fmark
+1 thanks for that. What if I am not using google maps, for instance just plotting movement of people on a floorplan?
Mawg
I suppose that I won't need to display thousands of points, just process them. For instance, on a floorplan I may show just a total number of people in each location (room, yard, whatever), but allow zoom to location level and show a few hundred points within that.or maybe I could combine points that are "close to each other" into groups?For google maps, we are probably talking fleet management/vehicle tracking. Is is unlikely that there would be thousands on one map unless it zoomed way out to country level, so combine points. At state/city level there might be a few 100.
Mawg
I am just kicking ideas about here and trying to get a feel for what is possible before committing to anything. And thank for the great feedback.
Mawg
+1  A: 

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?

ldsandon
Good points, thanks
Mawg
+1  A: 

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?

MarkRobinson
+1 Thanks for commenting. The image has to be clickable, but, yes, I can do that with a static image.
Mawg
+1  A: 

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.

mjustin
Nice, but the only browser supporting it already is Chrome, and lots of "experimental" server side support. It could be the future, but pretty difficult to use it right now.
ldsandon
I do like HTML, but it's scheduled to be finalized , when ? About 2022 IIRC. Bottom line is that conservative big business will insist on MSIE and does not like non-standardized stuff. +1 for a good suggestion, though
Mawg