<div dir="ltr">+1 to Andy's reply, I could not have said it better.<div><br></div><div>All mapscript implementations (java, c#, python, ruby, perl and tcl) share the same code base, with the language specific glue being automatically generated by swig.</div>
<div><br></div><div>PHP mapscript is the only exception.</div><div><br></div><div>Umberto</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 6, 2014 at 4:32 PM, Andy Colson <span dir="ltr"><<a href="mailto:andy@squeakycode.net" target="_blank">andy@squeakycode.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 1/6/2014 6:34 AM, Sajid Anwar wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I am wondering how to write a program (function) for Map server, which<br>
dynamically handle arbitrary shapefile, and will change the style like<br>
color etc, on the basis of attribute from shapefile. I want to develop<br>
and rendered choropleth map for arbitrary shapefile.<br>
<br>
I know that we can use MapScript languge like python for custom<br>
programming, and I already read some tutorial about python mapscript. I<br>
need help/direction about which scripting language is easy to use and<br>
more flexible and from where to start ,other link without Map-server<br>
website and example.<br>
<br>
<br>
I already use the Map file in cgi mode, but it is static and here we<br>
manually change the file(metadata) for each shape file. i am interested<br>
in a function /program which can handle styling for arbitrary shapefile.<br>
<br>
<br>
Thanks in advance<br>
<br>
<br>
sajid<br>
<br>
student<br>
<br>
</blockquote>
<br>
All languages are the same, and can do the same thing.  The question is not "which language is more flexable", but "which language do I know the best", or "what language would I enjoy learning for this project".<br>

<br>
I choose Perl.  Not because of all the rave reviews it gets, or its massive popularity, but because I know perl, I love it, I think in it.<br>
<br>
So pick a language that mapscript supports.  I can offer you the ideas I used to write my site, and you can implement them in any language.<br>
<br>
I use mod_perl, FastCGI, and uwsgi... all of which are pretty similar.<br>
<br>
I start out with a url like:<br>
<a href="http://maps.camavision.com/map/iowacityia" target="_blank">http://maps.camavision.com/<u></u>map/iowacityia</a><br>
<br>
I pull off the last word and stuff that into $xmap.<br>
Then I check the url for ether WMS or info, and if not found, I return a suitable index.html file:<br>
<br>
my $filename = MAPPATH."/$xmap.map";<br>
my $map = new mapscript::mapObj($filename);<br>
<br>
MAPPATH is outside the htdocs folder.<br>
<br>
Then, I've had reports where people have huge monitors so I need to make sure the maxsize if at least 4096.  I didnt want to check all my .map files, so I just check in mapscript:<br>
<br>
        if ($map->{maxsize} < 4096)<br>
        {<br>
                $map->{maxsize} = 4096;<br>
        }<br>
<br>
I load various values from the map file, like the bounding box:<br>
        my $bbox = $map->{extent};<br>
        $vars{'minx'} = $bbox->{minx};<br>
        $vars{'miny'} = $bbox->{miny};<br>
        $vars{'maxx'} = $bbox->{maxx};<br>
        $vars{'maxy'} = $bbox->{maxy};<br>
<br>
I generate some javascript for the index.html page:<br>
        $zoom = "var bb = new  OpenLayers.Bounds.fromArray([$<u></u>vars{'minx'}, $vars{'miny'}, $vars{'maxx'}, $vars{'maxy'}]);\n"<br>
        . "\t\t\tmap.zoomToExtent(bb, true);\n";<br>
<br>
And then I send it to the browser:<br>
  my $index = $config{$xmap}->{'index'} // 'index.html';<br>
  showTemplate($index, \%vars);<br>
<br>
This page will include the openlayers stuff and setup to render the map.  openlayers will turn around and request map images using the url param WMS.<br>
<br>
My code, when it sees a WMS requst does this:<br>
<br>
        $owreq = new mapscript::OWSRequest();<br>
        my @par = $web->paramNames();<br>
        for my $x (@par)<br>
        {<br>
                my $v = $web->param($x);<br>
                $owreq->setParameter($x, $v);<br>
        }<br>
        my $map = new mapscript::mapObj( MAPPATH."/$xmap.map" );<br>
<br>
It creates a request object, and copies all the url params into the owreq.<br>
<br>
And here is the part you will like.  If you pass along a parcel number:<br>
<a href="http://maps.camavision.com/map/iowacityia?pin=1004178001" target="_blank">http://maps.camavision.com/<u></u>map/iowacityia?pin=1004178001</a><br>
<br>
It dynamically creates a layer called annotate_pin (which is the blue highlight):<br>
<br>
        if ($layername =~ 'annotate_pin')<br>
        {<br>
                # did we get a click point?<br>
                my $cx = $web->param('LON');<br>
                my $cy = $web->param('LAT');<br>
                if ( defined($cx) && defined($cy))<br>
                {<br>
                        $xpin = getPin($cx, $cy);<br>
                }<br>
<br>
                $q = $db->prepare("select shapeid from $xmap.getpoint where pin = \$1");<br>
                $q->execute($xpin);<br>
<br>
                my $layer = $map->getLayerByName('parcels'<u></u>);<br>
                $layer->open();<br>
                my $newlayer = $map->getLayerByName('<u></u>annotate_pin');<br>
                $newlayer->{status} = $mapscript::MS_ON;<br>
<br>
                my $shp;<br>
                ($sid) = $q->fetchrow_array;<br>
                if (defined($sid))<br>
                {<br>
                        $shp = $layer->getShape(new mapscript::resultObj($sid));<br>
<br>
                }<br>
                $q = undef;<br>
                $layer->close();<br>
                my $shape = $shp->clone();<br>
                $newlayer->addFeature($shape);<br>
        }<br>
<br>
In the .map file, the layer annotate_pin exists, but is mostly empty. It only contains a STYLE for drawing, but no data.  I find the shape from the parcels layer, clone it (just that one parcel) and add it to the annotate_pin layer.<br>

<br>
This code is not the exact code I run.  I striped out a bunch to try and make it more readable.  On click of another parcel it sends an info url, which does almost the exact same thing to move the highlight.<br>
<br>
Also, you can see I'm doing queries to PostGIS and not using mapserver's query's.<br>
<br>
Hopefully this'll get you a start, although not exactly what you are looking for.<br>
<br>
I'm happy to answer questions.<br>
<br>
-Andy<br>
______________________________<u></u>_________________<br>
mapserver-users mailing list<br>
<a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">mapserver-users@lists.osgeo.<u></u>org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/mapserver-<u></u>users</a><br>
</blockquote></div><br></div>