[Mapserver-users] Draw circle with polygon
Gijs Epping
gijs at gijs.com
Wed Mar 17 07:04:48 PST 2004
Thanks for your answer but i was looking for this.
function createPoint( $x1, $y2, $programId, $radius)
{
GLOBAL $shpFile, $dbfFile;
// Create shape
$oShp = ms_newShapeObj(MS_SHAPE_POLYGON);
$oLine = ms_newLineObj();
$pointObj = ms_newPointObj();
for ($i = 0; $i <= 360; $i = $i + 10)
{
$x = $x1 + (cos($i * (22 / 7) / 180) * $radius);
$y = $y2 - (sin($i * (22 / 7) / 180) * $radius);
$pointObj->setXY($x, $y);
$oLine->add($pointObj);
}
$oShp->add($oLine);
$shpFile->addShape($oShp);
// Write attribute record
dbase_add_record($dbfFile, array($programId));
}
$shpFname = "/var/www/html/atmsv03/testpol";
$shpFile = ms_newShapeFileObj($shpFname, MS_SHP_POLYGON);
$dbfFile = dbase_create( $shpFname.".dbf", array(array("ID", "N", 5,
0)));
// geopoint1 and 2 and 100 is the radius
createPoint($punt[0], $punt[1], 1, 100);
$shpFile->free();
dbase_close($dbfFile);
// Set the buffer distance
$pt_layer = $map->getLayerByName("polygon");
$pt_layer->set("status", MS_ON);
$pt_layer->set("transparency", 50);
$pt_class = $pt_layer->getclass(0);
MAP FILE
LAYER
NAME "polygon"
TYPE POLYGON
STATUS OFF
DATA testpol
CLASS
NAME 'Europa'
COLOR 255 0 0
OUTLINECOLOR 0 0 0
END
END # layer
Thanks anyway.
Gijs
-----Oorspronkelijk bericht-----
Van: Lowell Filak [mailto:lfilak at medinaco.org]
Verzonden: woensdag 17 maart 2004 15:42
Aan: Gijs Epping; mapserver-users at lists.gis.umn.edu
Onderwerp: Re: [Mapserver-users] Draw circle with polygon
I think you may need to check out the symbolscale under the layer
object.
Also in you mapscript code you should not need to add a point to a line
object in order to add to a point shapefile.
$shpFile->addPoint(pointObj) should suffice.
HTH
Lowell
The following message was sent by "Gijs Epping" <gijs at gijs.com> on Wed,
17 Mar 2004 14:18:14 +0100.
> Hello,
>
> I am trying to draw a circle that has to scale with the map, I have
some
> code now (see below) but that doesn't do the trick it just shows a
> circle that doesn't scale with the map (It just stay's the same width
if
> I set a different extension).
>
> I think i need to create a polygon that is connected to a point, but I
> don't know how at the moment if somebody could give me a push in the
> right direction it would be great.
>
> Thanks in advance
> Gijs
>
>
> function createPoint( $x, $y, $programId )
> {
> GLOBAL $shpFile, $dbfFile;
>
> // Create shape
> $oShp = ms_newShapeObj(MS_SHAPE_POINT);
> $oLine = ms_newLineObj();
> $oLine->addXY($x, $y);
> $oShp->add($oLine);
> $shpFile->addShape($oShp); // Write attribute record
> dbase_add_record($dbfFile, array($programId));
> }
>
> $shpFname = "/var/www/html/atmsv03/proximity";
> $shpFile = ms_newShapeFileObj($shpFname, MS_SHP_POINT);
> $dbfFile = dbase_create( $shpFname.".dbf", array(array("ID", "N",
5,
> 0)));
>
> createPoint($punt[0], $punt[1], 1); // the points come from an area
> code point
>
> $shpFile->free();
> dbase_close($dbfFile);
>
> // Set the buffer distance
> $pt_layer = $map->getLayerByName("proximity");
> $pt_layer->set("status", MS_ON);
> $pt_class = $pt_layer->getclass(0);
>
>
>
>
> The map file part:
>
> LAYER
> NAME "proximity"
> data proximity
> STATUS off
> TYPE POINT
> SIZEUNITS meters
> TRANSPARENCY 50
> CLASS
> SIZE 1000
> NAME 'transcircle'
> SYMBOL 'transcircle'
> COLOR 255 0 0
> END
> END
> SYMBOL
> NAME 'transcircle'
> TYPE ELLIPSE
> POINTS 1 1
> END
> FILLED TRUE
> END
>
>
>
>
>
More information about the MapServer-users
mailing list