[Mapserver-users] Need Help with BTM Projection System on PHPMapScript >> ms_newprojectionobj()

Ishrar Hussain ishrarh at yahoo.com
Mon Jul 26 08:34:37 EDT 2004


First of all, many thanks to Merlos for his codes on
PointObj and LineObj for plotting maps on the fly. I
am also delighted to see that these codes are now
available on Wiki's website as well. This is really
great.

Now, before plotting the points of "latlong"
projection, I'm using the following code for
converting them to BTM projection system:

$projInObj = ms_newprojectionobj("proj=latlong");
$projOutObj = ms_newprojectionobj("Projection
parameters for BTM projection system");
$poPoint = ms_newpointobj();
$poPoint->setXY(23.59, 81.05);         
$poPoint->project($projInObj, $projOutObj);

(This is as per given in the class-reference of
PHP/MapScript)

I hope this will work. But before I can implement
this, I need the appropriate parameters for BTM
projection system, of which my shape files are, that I
already have in the bottom layers.

The followings are all the info that I have about the
BTM Projection System:

  Bangladesh Transverse Mercator (BTM) Projection.
(ISPAN 1992)

  ELLIPSOID : Everest 1830
  PROJECTION : Transverse Mercator
  CENTRAL MERIDIAN : 90o E
  FALSE EASTING : 500,000 m 
  FALSE NORTHING : -2,000,000 m


Now, I'm urgently in need of the code of how to put
the above information of this BTM projection system,
in the projection parameters of ms_newprojectionobj()
function.

I hope this will be enough for you to understand my
problem. So, if possible, please send me the
appropriate parameters for this BTM projection.

Thanks again, for everything.

Regards,
Ishrar

________________________


--- Merlos <merlos at tsc.uvigo.es> wrote:
> Hi,
> 
> Try out this nice code. I think it is extrapolable
> to any kind of shape, just 
> adding more lines to the shp object.
> 
> Regards. Juan M. Merlos
> 
> 
> This is the layer definition.
>   LAYER
>     GROUP "user"
>     NAME "lines"
>     METADATA
>         "label" "0,0 como la San Miguel"
>         "symbol_" "phone.png"
>     END #metadata
>     TYPE line
>     STATUS on
> #    FEATURE 
> #     POINTS 0.0 0.0 3.0 3.0 4.5 4.0 END
> #    END
>    CLASS
>        NAME "0"
>        TEMPLATE "ttt_query.html"
>        STYLE
>          COLOR 255 0 0 # red
>          MAXSIZE 300 # default 50
>          SIZE 16
>        END #style
>    END #class
>    TOLERANCE 8 
>    TOLERANCEUNITS pixels
> #pixels|feet|inches|kilometers|meters|miles|dd
>   END #layer
> 
> <?php
> 
> dl('php_mapscript.so');
> //dl('php_mapscript_42.dll'); //For WinDoS Users
> 
> //Convert pixels to map units got from
> PHPMapscriptSnippet1
> function click2map ($click_x, $click_y) {
>     global $map;
>     $e= &$map->extent; //Tip for saving typing time
>     $x_pct = ($click_x / $map->width);
>     $y_pct = 1 - ($click_y / $map->height);
>     $x_map = $e->minx + ( ($e->maxx - $e->minx) *
> $x_pct);
>     $y_map = $e->miny + ( ($e->maxy - $e->miny) *
> $y_pct);
> 
>     return array($x_map, $y_map);
> }
> 
> 
> // --------------- MAIN -----------------------
> 
> $map= ms_newMapObj('data/test2.map');
> 
> //Avoid register global=on;
> import_request_variables("gP", "");
> 
> //Convert pixels to map units
> $map_pt =
>
click2map($_POST['image_x'],$_POST['image_y'],$map->extent);
> 
> //Construct the line
> $line = ms_newLineObj();
> $line->addXY($map_pt[0],$map_pt[1]);
> if (is_array($prev_x)) {
>     foreach ($prev_x as $i => $x){
>         $line->addXY($x, $prev_y[$i]);
>     }
> }
> 
> 
> $shp = ms_newShapeObj(MS_SHAPE_LINE);
> $shp-> add($line);
> 
> $layer = $map->getLayerByName('lines');
> //$layer->open();
> $layer->addFeature($shp);
> 
> //Draw the map and add the point
> $img = $map->draw();
> //$pt->draw($map, $layer, $img, 0 ,'yuhuu');
> $url = $img->saveWebImage();
> 
> //Now add hidden fields to the form
> 
> 
> for($i=0;$i<$line->numpoints;$i++) {
>     $pt = $line->point($i);
>     $x = $pt->x;
>     $y = $pt->y;
>     $HTML_HIDDEN.="<input type=\"hidden\"
> name=\"prev_x[$i]\" value=\"$x\"/>";
>     $HTML_HIDDEN.="<input type=\"hidden\"
> name=\"prev_y[$i]\" value=\"$y\"/>";
> }
> 
> ?>
> 
> <html><head><title>Yapig</title></head>
> <body>
> <form method="post" action="query3.php" >
>    <input style="border:thin solid
> black;"type="image" name="image" 
> src="<?php echo$
>      <?php echo $HTML_HIDDEN ?>
> </form>
> <a href="query3.php">Clear</a>
> <pre>
> <?php
> echo "GET\n";
> print_r($_GET);
> echo "Point:\n";
> print_r($pt); ?>
> ?>
>  </body>
> 
> 
> 
> On Tuesday 20 July 2004 20:10, Ishrar Hussain wrote:
> > Dear Andy and Merlos,
> >
> > Thank you both so very much, as both of your codes
> > helped me a lot.
> >
> > I'm also looking forward to using LineObj of
> > PHP/MapScript. The sequence of code for drawing
> lines
> > on the fly seems a little different then drawing
> > points, as the points of a line need to be added
> one
> > by one.
> >
> > Please help me in this regard, if possible.
> > Thanks once again, for everything.
> >
> > Regards,
> > Ishrar
> >
> 
=== message truncated ===



		
_______________________________
Do you Yahoo!?
Express yourself with Y! Messenger! Free. Download now. 
http://messenger.yahoo.com



More information about the mapserver-users mailing list