how to build a geofence app.

Mark Thomas javaguru at IEEE.ORG
Sat Jun 24 08:30:56 EDT 2006


Luis,

Stephen is on the right track here.  I did this at a previous company by
letting the user zoom/pan to the ROI, then I had the user click 2
points; one the center point and the other a point on the wanted "edge"
of the ROI.  I then used the wz_jsgraphics.js library to draw both a
circle, the geofence, and its bounding box based off of these 2 points,
which created the radius of the circle.  Once the user was satisfied,
they could submit the geofence to the server for persistence.  

This method is easy if you only need square or circular geofences, but
if you need irregularly shaped polygons then you'll have to have your
users digitize points, just like Stephen said  previously.

Here's some sample code for drawing the geofence using wz_jsgraphics.js:


            lyr.drawLine(x1,y1,x2,y2);
            lyr.paint();
            lyr.setColor("#ff0000");
            var radius = Math.sqrt( Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
            var x = x1 - radius;
            var y = y1 - radius;
            var w = radius * 2;
            var h = w;
            lyr.drawEllipse(x, y, w, h);
            lyr.paint();
            lyr.setColor("#00ff00");
            lyr.drawRect(x, y, w, h);
            lyr.paint();


On Sat, 2006-06-24 at 00:00 -0500, MAPSERVER-USERS automatic digest
system wrote:

> Skip repetitive navigational links
> L-Soft - Home of the LISTSERV mailing list manager LISTSERV(R) 14.3
>    MAPSERVER-USERS Digest - 22 Jun 2006 to 23 Jun 2006 (#2006-176)
> 
> 
> Table of contents:
> 
>       * ERROR: column 'oid' does not exist 
>       * No query layer defined 
>       * Having trouble with running a demo 
>       * templete problem 
>       * query raster layer (2) 
>       * NQUERY problem 
>       * msWMSLoadGetParams (2) 
>       * Mapscript ,Mono, Apache and Linux : a great story (heap
>         corruption with geos) 
>       * Thread-safety in mapscript_csharp.dll? (5) 
>       * Deleting from a shapefile 
>       * JavaMapscript SIGSEGV 
>       * WMS Layer Problem 
>       * how to build a geofence app. (3) 
>       * Mapscript C# compilation (4) 
>       * LEGEND + CLASS 
>       * Class expression and PostGIS
>         
>         
>      1. ERROR: column 'oid' does not exist
>               * Re: ERROR: column 'oid' does not exist (06/22)
>                 From: Tyler Mitchell <tylermitchell at SHAW.CA>
>                 
>         
>      2. No query layer defined
>               * No query layer defined (06/23)
>                 From: absar ali <absarzaidi at YAHOO.COM>
>                 
>         
>      3. Having trouble with running a demo
>               * Re: Having trouble with running a demo (06/23)
>                 From: Daniel Goetz <madprof at GMX.CH>
>                 
>         
>      4. templete problem
>               * templete problem (06/23)
>                 From: absar ali <absarzaidi at YAHOO.COM>
>                 
>         
>      5. query raster layer
>               * Re: query raster layer (06/23)
>                 From: "Bart van den Eijnden (OSGIS)"
>                 <bartvde at XS4ALL.NL> 
>               * Re: query raster layer (06/23)
>                 From: Giorgio Libert <giorgio.liberta at JRC.IT>
>                 
>         
>      6. NQUERY problem
>               * NQUERY problem (06/23)
>                 From: DjwStone <D.Stone at ED.AC.UK>
>                 
>         
>      7. msWMSLoadGetParams
>               * Re: msWMSLoadGetParams (06/23)
>                 From: Marcos Cobea <marcoscobena at GMAIL.COM> 
>               * Re: msWMSLoadGetParams (06/23)
>                 From: "Bart van den Eijnden (OSGIS)"
>                 <bartvde at XS4ALL.NL>
>                 
>         
>      8. Mapscript ,Mono, Apache and Linux : a great story (heap
>         corruption with geos)
>               * Re: Mapscript ,Mono, Apache and Linux : a great story
>                 (heap corruption with geos) (06/23)
>                 From: Tamas Szekeres <szekerest at GMAIL.COM>
>                 
>         
>      9. Thread-safety in mapscript_csharp.dll?
>               * Thread-safety in mapscript_csharp.dll? (06/23)
>                 From: Jeff Dege <jdege at KORTERRA.COM> 
>               * Re: Thread-safety in mapscript_csharp.dll? (06/23)
>                 From: Umberto Nicoletti <umberto.nicoletti at GMAIL.COM> 
>               * Re: Thread-safety in mapscript_csharp.dll? (06/23)
>                 From: Tamas Szekeres <szekerest at GMAIL.COM> 
>               * Re: Thread-safety in mapscript_csharp.dll? (06/23)
>                 From: Jeff Dege <jdege at KORTERRA.COM> 
>               * Re: Thread-safety in mapscript_csharp.dll? (06/24)
>                 From: Tamas Szekeres <szekerest at GMAIL.COM>
>                 
>         
>     10. Deleting from a shapefile
>               * Deleting from a shapefile (06/23)
>                 From: Antonio Iandolo <aiandolo at GRUPPOAS.IT>
>                 
>         
>     11. JavaMapscript SIGSEGV
>               * Re: JavaMapscript SIGSEGV (06/23)
>                 From: Tamas Szekeres <szekerest at GMAIL.COM>
>                 
>         
>     12. WMS Layer Problem
>               * WMS Layer Problem (06/23)
>                 From: "M.L. Jackson" <mljacks2 at HOTMAIL.COM>
>                 
>         
>     13. how to build a geofence app.
>               * how to build a geofence app. (06/23)
>                 From: Luis Trevio Huerta <ltrevino at GPOBSI.COM.MX> 
>               * Re: how to build a geofence app. (06/23)
>                 From: Stephen Woodbridge <woodbri at SWOODBRIDGE.COM> 
>               * Re: how to build a geofence app. (06/23)
>                 From: Luis Trevio Huerta <ltrevino at GPOBSI.COM.MX>
>                 
>         
>     14. Mapscript C# compilation
>               * Mapscript C# compilation (06/23)
>                 From: rock well <rockwell_001 at YAHOO.COM> 
>               * Re: Mapscript C# compilation (06/24)
>                 From: Tamas Szekeres <szekerest at GMAIL.COM> 
>               * Re: Mapscript C# compilation (06/23)
>                 From: rock well <rockwell_001 at YAHOO.COM> 
>               * Re: Mapscript C# compilation (06/24)
>                 From: Tamas Szekeres <szekerest at GMAIL.COM>
>                 
>         
>     15. LEGEND + CLASS
>               * LEGEND + CLASS (06/23)
>                 From: salah jubeh <s_jubeh at YAHOO.COM>
>                 
>         
>     16. Class expression and PostGIS
>               * Class expression and PostGIS (06/24)
>                 From: Nigel Gilbert <n.gilbert at SURREY.AC.UK>
> 
> 
> 
> ______________________________________________________________________
> Powered by LISTSERV(R) Browse the MAPSERVER-USERS online archives. 
> email message attachment
> 
> > -------- Forwarded Message --------
> > From: Tyler Mitchell <tylermitchell at SHAW.CA>
> > Subject: Re: ERROR: column 'oid' does not exist
> > Date: Thu, 22 Jun 2006 22:56:38 -0700
> > 
> > 
> > On 22-Jun-06, at 8:50 PM, Aaron Koning wrote:
> > 
> > > If you imported the spatial layer with shp2pgsql or OGR programs,  
> > > their should be a unique id field already (e.g. 'gid' with  
> > > shp2pgsql). You can tell MapServer to use this unique id field  
> > > instead of oid in the LAYER -> DATA variable of your MapFile.
> > >
> > > Example:
> > >      DATA "the_geom FROM roads AS foo USING UNIQUE gid"
> > >
> > That's a much better - thanks Aaron.  I'm told by postgresql gurus  
> > not to ever use the oid... that it should only be used for internal  
> > database key purposes and cannot be relied on as stable.  Oh well,  
> > thanks for pointing out a better option.
> > 
> > Tyler
> 
> email message attachment
> 
> > -------- Forwarded Message --------
> > From: absar ali <absarzaidi at YAHOO.COM>
> > Subject: No query layer defined
> > Date: Fri, 23 Jun 2006 00:30:58 -0700
> > 
> > 
> > GRRRRRRRRRRRRRR,
> >    
> >   i am using the following line to query the map 
> >    
> >   window.open("/cgi-bin/mapserv.exe?map=karachi.map&mode=ITEMQUERY&qstring=charge&layer=charge_region");
> >    
> >   actually stive lime gave me this, but its giving following error
> >   "msQueryByAttribute():General error message. No query layer defined"
> >    
> >   below is my map file, please check is there any thing wrong in my map file. I am using ka-map as my map client. my kamap is woring fine it displays all the layers but the hell query is not woring another thing my maps are not georeferenced so i cant use QueryByPoint.
> >    
> >   Please help me n guide me i am very depressed.
> >   Regards,
> >    
> >   Absar Ali
> >   ____________________________________________________
> >   
> > NAME Karachi
> > STATUS ON
> >   
> > SIZE 800 600
> > SHAPEPATH "karachiShape"
> >   WEB
> >  IMAGEPATH "C:/tmp/"
> >  IMAGEURL "C:/tmp/"
> > END
> >   
> > EXTENT 40.2283 -5.55177 49.7201 1.8823
> > UNITS dd
> > IMAGECOLOR 255 255 255
> > IMAGETYPE png
> >   QUERYMAP
> >  STATUS ON
> >  # the map is queryable by default
> >  STYLE HILITE
> >  # the selected object is highligthed
> >  COLOR 255 0 0
> >  SIZE -1 -1 
> > END
> >   LEGEND
> >     KEYSIZE 18 12
> >     LABEL
> >       TYPE BITMAP
> >       SIZE MEDIUM
> >       COLOR 0 0 89
> >     END
> >     STATUS ON
> >   END
> >   LAYER
> >   NAME charge_region
> >   TEMPLATE "template/ka.html"
> >   METADATA
> >   "queryable" "true" 
> >   END
> >   TYPE POLYGON
> >   STATUS ON
> >   DATA CHARGE_region
> >   LABELITEM "name"
> >   CLASS
> >     NAME "CHARGE_region"
> >     COLOR 146 154 155
> >     OUTLINECOLOR 43 170 115
> >          LABEL
> >          MINFEATURESIZE 40
> >          MINDISTANCE 150
> >          POSITION CC
> >          SIZE TINY
> >          COLOR 0 0 0
> >       END 
> >   END
> > END
> > LAYER
> >   NAME circle_region
> >   TEMPLATE "template/ka.html"
> >   METADATA
> >   "queryable" "true" 
> >   END
> >   TYPE POLYGON
> >   STATUS OFF
> >   DATA CIRCLE_region
> >   LABELITEM "name"
> >   CLASS
> >     NAME "CIRCLE_region"
> >     COLOR 90 15 155
> >     OUTLINECOLOR 200 205 133
> >          LABEL
> >          MINFEATURESIZE 40
> >          MINDISTANCE 150
> >          POSITION CC
> >          SIZE TINY
> >          COLOR 0 0 0
> >       END 
> >   END
> > END
> > LAYER
> >   NAME important_locations_point
> >   METADATA
> >   "queryable" "true" 
> >   END
> >   TYPE POINT
> >   STATUS OFF
> >   DATA "IMPORTANT LOCATIONS_point"
> >   CLASS
> >     NAME "IMPORTANT LOCATIONS_point"
> >   END
> > END
> > LAYER
> >   NAME town_region
> >    TEMPLATE "template/ka.html"
> >   METADATA
> >   "queryable" "true" 
> >   END
> >   TYPE POLYGON
> >   STATUS OFF
> >   DATA TOWN_region
> >   LABELITEM "name"
> >   CLASS
> >     NAME "TOWN_region"
> >     COLOR 77 224 186
> >     OUTLINECOLOR 244 237 138
> >          LABEL
> >          MINFEATURESIZE 40
> >          MINDISTANCE 150
> >          POSITION CC
> >          SIZE TINY
> >          COLOR 0 0 0
> >       END 
> >   END
> > END
> > LAYER
> >   NAME town_text
> >    TEMPLATE "template/ka.html"
> >   METADATA
> >   "queryable" "true" 
> >   END
> >   TYPE POINT
> >   STATUS OFF
> >   DATA TOWN_text
> >   CLASS
> >     NAME "TOWN_text"
> >   END
> > END
> > LAYER
> >   NAME union_council_region
> >    TEMPLATE "template/ka.html"
> >   METADATA
> >   "queryable" "true" 
> >   END
> >   TYPE POLYGON
> >   STATUS ON
> >   DATA "UNION COUNCIL_region"
> >    LABELITEM "name"
> >   CLASS
> >     NAME "UNION COUNCIL_region"
> >     COLOR 37 118 61
> >     OUTLINECOLOR 220 54 199
> >          LABEL
> >          MINFEATURESIZE 40
> >          MINDISTANCE 150
> >          POSITION CC
> >          SIZE TINY
> >          COLOR 0 0 0
> >       END 
> >   END
> > END
> > END 
> >    
> > 
> >  			

Mark Thomas
Sun Certified Java 5 Programmer
Sun Certified Java 2 Programmer
Sun Certified Web Component Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060624/34ed8a01/attachment.html


More information about the mapserver-users mailing list