MapScript - Show numbered coordinates as numbered dots on a map

Mark Thomas spatialguru.net at GMAIL.COM
Mon Dec 4 08:12:46 EST 2006


I agree with Kai. This is typically what I do with data in CSV,
tab-delimited, XML, KML, etc.  I write a shell script of XSLT transform to
convert to a SQL file I can load into PostGIS, the use the pgsql2shp program
top convert to shapefile.  This would be more ideal than keeping in PostGIS
as MapServer is optimized for shapefiles.  Other than that you could try
using C# MapScript to generate layers on-the-fly

here's a PHP MapScript example:

    function drawPoint($oMap,$x,$y,$text = '') {
        $nSymbolId = ms_newSymbolObj($oMap, "my_point");
        $oSymbol = $oMap->getsymbolobjectbyid($nSymbolId);
        $oSymbol->set("type", MS_SYMBOL_ELLIPSE);
        $oSymbol->set("filled", MS_TRUE);
        $aPoints[0] = 1;
        $aPoints[1] = 1;
        $oSymbol->setpoints($aPoints);

        // Create a layer to hold circle
        $oLayerPoints = ms_newLayerObj($oMap);
        $oLayerPoints->set("name", "my_point_outline" .
mt_rand(abs(ceil($x)),abs(ceil($y))));
        $oLayerPoints->set("type", MS_LAYER_POINT);
        $oLayerPoints->set("status", MS_DEFAULT);
        $pointObj = ms_newLineObj();
        $pointObj->addXY($x,$y);
        $oPointShape = ms_newShapeObj(MS_SHAPE_POINT);
        $oPointShape->add($pointObj);
        if ($text != '') {
            $oPointShape->set("text", $text);
        }
        $oLayerPoints->addFeature($oPointShape);

        // Create a class object to set feature drawing styles.
        $oMapClass = ms_newClassObj($oLayerPoints);
        // Create a style object defining how to draw features
        $oPointStyle = ms_newStyleObj($oMapClass);
        $oPointStyle->color->setRGB(250,0,0);
        $oPointStyle->outlinecolor->setRGB(255,255,255);
        $oPointStyle->set("symbolname", "my_point");
        $oPointStyle->set("size", "10");

        // Create label settings for drawing text labels
        $oMapClass->label->set( "position", MS_AUTO);
        $oMapClass->label->color->setRGB(250,0,0);
        $oMapClass->label->outlinecolor->setRGB(255,255,255);
    }



On 12/4/06, Kai Behncke <kbehncke at igf.uni-osnabrueck.de> wrote:
>
> On Mon, 4 Dec 2006 11:16:22 +0100, Martijn van Exel wrote
> > Dear scripters,
> >
> > I have a tab-separated text file containing numbered points (number
> > / x / y). I want to parse this file and put the points on the map as
> > numbered dots. How do I go about doing this in (C#) MapScript? Can I
> > determine the size of the dots and the size, font and colour of the
> > numbers? Can I make the numbers appear centered inside the dots?
> >
> > Much appreciated,
> >
> Hello Martijn,
> this sounds quite interesting.
> You can do this easily with PHP/Mapscript.
> You can parse the text file in a way, that the x and y -koordinates are
> written in a database (PostgreSQL/PostGIS or even Mysql (even without the
> spatial extension)).
>
> You can determine the size of the dots.
> For example, if your data are in postgresql/postgis, use a new Layer
> like:
>
> LAYER
>      NAME "poi"
>      STATUS on
>      TYPE point
>      LABELCACHE on
>
>   CONNECTIONTYPE postgis
>   CONNECTION "user=postgres dbname=data host=localhost port=5432"
>   DATA "the_geom from yourtable"
> LABELITEM 'punktnumber'
>     CLASS
>
>
>   STYLE
>    SYMBOL punkt
> COLOR     120 0 0
> SIZE 14     # this determines the size of the dot
>
> END
>
>
>             LABEL #this determines the label.
> #You can determine size, font and colour of the
> # numbers. And you can make the numbers appear centered inside the dots.
>                TYPE truetype
>                FONT "arialbd"
>                SIZE 8
>                COLOR 0 0 0
>                OUTLINECOLOR 255 255 255
>                POSITION cc
>                ANGLE auto
>                MINFEATURESIZE auto
>           END
>      END
> END
>
> Regards, Kai
> --
> Dipl.-Geogr. Dipl.-Umweltw. Kai Behncke
>
> Institut für Geoinformatik und Fernerkundung (IGF)
> Universität Osnabrück
> Kolpingstr. 7
> 49074 Osnabrück
>
> Raum: 01/308
> Tel.: +49 541 969-4450
> E-Mail: mailto:kbehncke at igf.uni-osnabrueck.de
> Web:  http://www.igf.uni-osnabrueck.de
>



-- 
Regards,

Mark Thomas
spatialguru.net at gmail.com
205.529.9013

"Commit to the Lord whatever you do,
    and your plans will succeed." - Proverbs 16:3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20061204/aec290af/attachment.html


More information about the mapserver-users mailing list