[Cartoweb-users] How to draw a circle
Oliver Christen
oliver.christen at camptocamp.com
Fri Feb 15 02:37:31 EST 2008
Hi Dirk
mmm, im not sure.
Did you do a cw3setup.php --install ? as it is usualy needed to generate the
correct paths and symbolic links to files that are overided in projects.
at worst, simply put the icons in the main outline/htdocs/gfx folder (I know
it is not a proper solution)
Btw, I integrated the functionality into Cartoweb cvs some days ago with a
bit more "correct" code.
Im joining it if you want to have a try.
regards
Oliver
----- Original Message -----
From: "Dirk Jesko" <ml.dje at geocontent.de>
To: "Oliver Christen" <oliver.christen at camptocamp.com>
Cc: "Cartoweb Users" <cartoweb-users at lists.maptools.org>
Sent: Friday, February 15, 2008 8:13 AM
Subject: Re: [Cartoweb-users] How to draw a circle
> Hello Oliver,
>
> yesterday we applied the patch to one of our Cartoweb projects. Everything
> works fine, except the tool bar icon. Even thought it is in the same
> folder as the other outline icons, it is not displayed. Looking at the
> generated html I found, that the src attribute of the image is incorrect.
> The "outline_circle" looks like this
>
> src="outline/gfx/outline_circle.png"
>
> the others like this
>
> src="infogis/outline/gfx/outline_poly.png"
>
> I.e. the project name is missing and therefore, the image can not be
> found. Since the tool bar is generated automatically, I do not know, why
> this happens. Do you have any idea?
>
> Regards,
> Dirk
>
>
>
> Oliver Christen schrieb:
>> circle are not yet implemented in the current version or Cartoweb
>> but here is a patch that should enable it.
>> I did it myself because explaining you what to do would have taken me the
>> same amount of time.
>> I dont provide the tool icon though.
>>
>> regards
>> Oliver
>>
>>> Hi,
>>>
>>> I would like to know if it's possible to draw a circle (center and
>>> radius defined by the user) with the plugin "Outline" modified or with
>>> another solution?
>>>
>>> Thanks
>>>
>>> Patrick BERANGER
>>> Pôle Modernisation / Système d'Information Géographique
>>> DRE Rhône-Alpes / DDE Rhône
>>> Tél : 04 78 63 39 62
>>>
>>>
>>> _______________________________________________
>>> Cartoweb-users mailing list
>>> Cartoweb-users at lists.maptools.org
>>> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Cartoweb-users mailing list
>> Cartoweb-users at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>>
>
-------------- next part --------------
? plugins/outline/htdocs/gfx/outline_circle.gif
Index: documentation/user_manual/source/user/annotate.xml
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/documentation/user_manual/source/user/annotate.xml,v
retrieving revision 1.24
diff -u -r1.24 annotate.xml
--- documentation/user_manual/source/user/annotate.xml 13 Dec 2007 07:39:43 -0000 1.24
+++ documentation/user_manual/source/user/annotate.xml 8 Feb 2008 09:21:13 -0000
@@ -63,6 +63,11 @@
weightOutlinePoly<indexterm><primary>weightOutlinePoly</primary></indexterm>:
see weightOutlinePoint (default to 73) </para>
</listitem>
+ <listitem>
+ <para>
+ weightOutlineCircle<indexterm><primary>weightOutlineCircle</primary></indexterm>:
+ see weightOutlinePoint (default to 74) </para>
+ </listitem>
</itemizedlist>
</sect2>
</sect1>
@@ -193,6 +198,11 @@
<screen>http://www.example.com/cartoweb/myproject.php?outline_poly=611748,5232242;748204,5232242;748204,5050300;611748,5050300;611748,5232242</screen>
</para>
</listitem>
+ <listitem>
+ <para>outline_circle
+ <screen>http://www.example.com/cartoweb/myproject.php?outline_circle=611748,5232242;50000</screen>
+ </para>
+ </listitem>
</itemizedlist>
<note>
<para>If you do not want to have persistent outline, you can add the
Index: documentation/user_manual/source/user/config.xml
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/documentation/user_manual/source/user/config.xml,v
retrieving revision 1.42
diff -u -r1.42 config.xml
--- documentation/user_manual/source/user/config.xml 5 Nov 2007 10:08:44 -0000 1.42
+++ documentation/user_manual/source/user/config.xml 8 Feb 2008 09:19:57 -0000
@@ -421,6 +421,11 @@
</listitem>
<listitem>
<para>
+ weightOutlineCircle: 74
+ </para>
+ </listitem>
+ <listitem>
+ <para>
weightDistance: 80
</para>
</listitem>
Index: htdocs/js/dhtmlInit.js
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/htdocs/js/dhtmlInit.js,v
retrieving revision 1.25
diff -u -r1.25 dhtmlInit.js
--- htdocs/js/dhtmlInit.js 20 Nov 2007 07:46:47 -0000 1.25
+++ htdocs/js/dhtmlInit.js 8 Feb 2008 08:03:09 -0000
@@ -428,6 +428,33 @@
};
};
/***** OUTLINE ****/
+Map.prototype.outline_circle = function(aDisplay) {
+ this.resetMapEventHandlers();
+ this.setCurrentLayer('outline_poly');
+ this.getDisplay(aDisplay).setTool('draw.circle');
+
+ this.onNewFeature = function(aFeature) {
+ this.onToolUnset();
+ };
+ this.onFeatureInput = this.onFeatureChange = function(aFeature) {
+ fillForm(aFeature);
+ if (typeof addLabel == 'undefined')
+ doSubmit();
+ else
+ addLabel(circleDefaultLabel, mouse_x, mouse_y);
+ };
+ this.onToolUnset = function() {
+ //clear the outline_poly's display layer
+ this.getDisplay(aDisplay).clearLayer('outline_poly');
+ this.onCancel();
+ };
+ this.onCancel = function() {
+ if (typeof hideLabel != 'undefined')
+ hideLabel();
+ emptyForm();
+ };
+};
+
Map.prototype.outline_poly = function(aDisplay) {
this.resetMapEventHandlers();
this.setCurrentLayer('outline_poly');
Index: plugins/outline/client/ClientOutline.php
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/plugins/outline/client/ClientOutline.php,v
retrieving revision 1.59
diff -u -r1.59 ClientOutline.php
--- plugins/outline/client/ClientOutline.php 5 Nov 2007 10:08:44 -0000 1.59
+++ plugins/outline/client/ClientOutline.php 8 Feb 2008 07:51:10 -0000
@@ -58,6 +58,12 @@
* @var StyleOverlay
*/
public $polygonStyle;
+
+ /**
+ * Circle radius
+ * @var radius
+ */
+ public $radius;
}
/**
@@ -121,6 +127,7 @@
const TOOL_LINE = 'outline_line';
const TOOL_RECTANGLE = 'outline_rectangle';
const TOOL_POLYGON = 'outline_poly';
+ const TOOL_CIRCLE = 'outline_circle';
/**
* Constructor
@@ -156,6 +163,7 @@
$this->outlineState->pointStyle = new StyleOverlay();
$this->outlineState->lineStyle = new StyleOverlay();
$this->outlineState->polygonStyle = new StyleOverlay();
+ $this->outlineState->radius = false;
}
/**
@@ -172,8 +180,7 @@
* @see ToolProvider::handleMainmapTool()
*/
public function handleMainmapTool(ToolDescription $tool,
- Shape $mainmapShape) {
-
+ Shape $mainmapShape) {
return $mainmapShape;
}
@@ -197,6 +204,7 @@
new ToolDescription(self::TOOL_LINE, true, 71),
new ToolDescription(self::TOOL_RECTANGLE, true, 72),
new ToolDescription(self::TOOL_POLYGON, true, 73),
+ new ToolDescription(self::TOOL_CIRCLE, true, 74),
);
}
@@ -211,9 +219,10 @@
public function filterGetRequest(FilterRequestModifier $request) {
// gets geometry type from GET request
$this->geomType = '';
- $poly = $request->getValue('outline_poly');
- $line = $request->getValue('outline_line');
- $point = $request->getValue('outline_point');
+ $poly = $request->getValue(self::TOOL_POLYGON);
+ $line = $request->getValue(self::TOOL_LINE);
+ $point = $request->getValue(self::TOOL_POINT);
+ $circle = $request->getValue(self::TOOL_CIRCLE);
// set correct parameters for new shape depending on type
if (!empty($poly)) {
@@ -228,6 +237,10 @@
$this->geomType = $tool = self::TOOL_POINT;
$selection_coords = $point;
$selection_type = 'point';
+ } elseif (!empty($circle)) {
+ $this->geomType = $tool = self::TOOL_CIRCLE;
+ $selection_coords = $circle;
+ $selection_type = 'circle';
} else {
return;
}
@@ -235,7 +248,6 @@
$request->setValue('selection_type', $selection_type);
$request->setValue('tool', $tool);
}
-
/**
* @see GuiProvider::handleHttpPostRequest()
*/
@@ -277,6 +289,13 @@
$this->getHttpValue($request, 'outline_polygon_transparency');
$shape = $this->cartoclient->getHttpRequestHandler()->handleTools($this);
+
+ // allow circle radius to be set by hand, under conditions
+ if ($request['tool'] == self::TOOL_CIRCLE &&
+ !empty($request['outline_circle_radius']) && $shape->radius == 0) {
+ $shape->radius = $this->outlineState->radius =
+ $this->getHttpValue($request, 'outline_circle_radius');
+ }
if ($shape) {
$this->handleShape($shape, $request);
@@ -318,6 +337,7 @@
case self::TOOL_RECTANGLE:
case self::TOOL_POLYGON:
+ case self::TOOL_CIRCLE:
$styledShape->shapeStyle = clone $this->outlineState->polygonStyle;
break;
@@ -408,6 +428,8 @@
$this->outlineState->polygonStyle->color->getHex(),
'outline_polygon_transparency_selected' =>
$this->outlineState->polygonStyle->transparency,
+
+ 'outline_circle_radius' => $this->outlineState->radius,
'pathToSymbols' => $this->symbols->pathToSymbols,
'symbolType' => $this->symbols->symbolType,
@@ -577,6 +599,17 @@
protected function getShape($type, $values) {
switch ($type) {
+ case self::TOOL_CIRCLE :
+ $points = Utils::parseArray($values, ';');
+ if (sizeOf($points) != 2) return false;
+
+ $shape = new Circle;
+ $xy = Utils::parseArray($points[0], ',');
+ $shape->x = $xy[0];
+ $shape->y = $xy[1];
+ $shape->radius = $points[1];
+ return $shape;
+ break;
case self::TOOL_POLYGON :
$points = Utils::parseArray($values, ';');
if (sizeOf($points) <= 0) return false;
Index: plugins/outline/htdocs/css/outline.css
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/plugins/outline/htdocs/css/outline.css,v
retrieving revision 1.4
diff -u -r1.4 outline.css
--- plugins/outline/htdocs/css/outline.css 5 Jan 2006 10:26:51 -0000 1.4
+++ plugins/outline/htdocs/css/outline.css 8 Feb 2008 08:42:20 -0000
@@ -3,7 +3,8 @@
margin-bottom:2px;
}
.outl_block_center {
- text-align: center;
+ /*text-align: center;*/
+ padding-left: 20px;
}
.outl_symbol_block, .outl_color_block {
width:30px;
@@ -16,9 +17,11 @@
.outl_symbol_block {
height:30px;
+ margin-left:105px; /* to leave space for outl_label */
}
.outl_color_block {
height:16px;
+ margin-left:105px; /* to leave space for outl_label */
}
.outl_block_left input {
margin: inherit;
@@ -34,4 +37,12 @@
padding:10px;
background-color:#f5f5f5;
border:1px dashed #dfdfdf;
+}
+.outl_label {
+ float: left;
+ width: 105px;
+}
+
+.outl_color_hex {
+ margin-left:105px; /* to leave space for outl_label */
}
\ No newline at end of file
Index: plugins/outline/htdocs/js/outline.js
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/plugins/outline/htdocs/js/outline.js,v
retrieving revision 1.12
diff -u -r1.12 outline.js
--- plugins/outline/htdocs/js/outline.js 9 Jul 2007 07:26:44 -0000 1.12
+++ plugins/outline/htdocs/js/outline.js 8 Feb 2008 08:44:37 -0000
@@ -56,6 +56,9 @@
mainmap.outline_poly('map');
setActiveToolButton('outline_poly');
break;
+ case 'outline_circle_radius' :
+ mainmap.outline_circle('map');
+ setActiveToolButton('outline_circle');
}
}
@@ -71,7 +74,7 @@
var onFocusElements = new Array('outline_point_size','outline_point_color',
'outline_line_size','outline_line_color','outline_line_transparency',
'outline_polygon_outline_color','outline_polygon_background_color',
- 'outline_polygon_transparency');
+ 'outline_polygon_transparency','outline_circle_radius');
for (var i = 0; i < onClickElements.length; i++){
elm = xGetElementById(onClickElements[i]);
Index: plugins/outline/server/ServerOutline.php
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/plugins/outline/server/ServerOutline.php,v
retrieving revision 1.55
diff -u -r1.55 ServerOutline.php
--- plugins/outline/server/ServerOutline.php 26 Oct 2007 12:56:19 -0000 1.55
+++ plugins/outline/server/ServerOutline.php 7 Feb 2008 08:02:48 -0000
@@ -71,6 +71,13 @@
$p->addXY($shape->maxx, $shape->miny);
$p->addXY($shape->minx, $shape->miny);
$p->addXY($shape->minx, $shape->maxy);
+ } else if ($className == 'Circle') {
+ $f = ms_newShapeObj(MS_SHAPE_POLYGON);
+ for ($i = 0; $i <= 360; $i = $i + 10) {
+ $x = $shape->x + (cos($i * (22 / 7) / 180) * $shape->radius);
+ $y = $shape->y - (sin($i * (22 / 7) / 180) * $shape->radius);
+ $p->addXY($x, $y);
+ }
} else {
if ($className == 'Line') {
$f = ms_newShapeObj(MS_SHAPE_LINE);
@@ -278,6 +285,7 @@
break;
case 'Rectangle':
case 'Polygon':
+ case 'Circle':
$this->drawPolygon($shape, $maskMode);
break;
default:
Index: plugins/outline/templates/outline.tpl
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/plugins/outline/templates/outline.tpl,v
retrieving revision 1.19
diff -u -r1.19 outline.tpl
--- plugins/outline/templates/outline.tpl 9 Jul 2007 07:26:29 -0000 1.19
+++ plugins/outline/templates/outline.tpl 8 Feb 2008 08:53:21 -0000
@@ -14,28 +14,24 @@
<legend>{t}Point{/t}</legend>
<div class="outl_block_center">
- {t}symbol{/t}:
- <center>
+ <span class="outl_label" >{t}symbol{/t}:</span>
<div id="outline_point_symbol_d" class="outl_symbol_block" style="{if $outline_point_symbol_selected != ''}background-image: url({$pathToSymbols}{$outline_point_symbol_selected}.{$symbolType});{/if}"
onclick="javascript:toolPicker('4','outline_point_symbol');" {if $outline_point_symbol_selected != ''}title="{t}{$outline_point_symbol_selected}{/t}"{/if} ></div>
- </center>
</div>
<input type="hidden" id="outline_point_symbol" name="outline_point_symbol" value="{$outline_point_symbol_selected}" />
<div class="outl_block_center">
- {t}size{/t}:<br /><input type="text" id="outline_point_size" name="outline_point_size" size="3" value="{$outline_point_size_selected}" />
+ <span class="outl_label" >{t}size{/t}:</span><input type="text" id="outline_point_size" name="outline_point_size" size="3" value="{$outline_point_size_selected}" />
</div>
<div class="outl_block_center">
- {t}color{/t}:
- <center>
+ <span class="outl_label" >{t}color{/t}:</span>
<div id="outline_point_color_d" class="outl_color_block" style="{if $outline_point_color_selected != ''}background-color:{$outline_point_color_selected};{/if}" onclick="javascript:toolPicker('1','outline_point_color');" ></div>
- </center>
- <input type="text" id="outline_point_color" name="outline_point_color" size="7" value="{$outline_point_color_selected}" />
+ <input type="text" id="outline_point_color" name="outline_point_color" class="outl_color_hex" size="7" value="{$outline_point_color_selected}" />
</div>
<div class="outl_block_center">
- {t}transparency{/t}:<br />
+ <span class="outl_label" >{t}transparency{/t}:</span>
<input type="text" id="outline_point_transparency" name="outline_point_transparency" size="3" value="{$outline_point_transparency_selected}" />
</div>
@@ -45,48 +41,54 @@
<legend>{t}Line{/t}</legend>
<div class="outl_block_center">
- {t}border size{/t}:<br />
+ <span class="outl_label" >{t}border size{/t}:</span>
<input type="text" id="outline_line_size" name="outline_line_size" size="3" value="{$outline_line_size_selected}" />
</div>
<div class="outl_block_center">
- {t}color{/t}:
- <center>
+ <span class="outl_label" >{t}color{/t}:</span>
<div id="outline_line_color_d" class="outl_color_block" style="{if $outline_line_color_selected != ''}background-color:{$outline_line_color_selected};{/if}" onclick="javascript:toolPicker('1','outline_line_color');" ></div>
- </center>
- <input type="text" id="outline_line_color" name="outline_line_color" size="7" value="{$outline_line_color_selected}" />
+ <input type="text" id="outline_line_color" name="outline_line_color" size="7" class="outl_color_hex" value="{$outline_line_color_selected}" />
</div>
<div class="outl_block_center">
- {t}transparency{/t}:<br />
+ <span class="outl_label" >{t}transparency{/t}:</span>
<input type="text" id="outline_line_transparency" name="outline_line_transparency" size="3" value="{$outline_line_transparency_selected}" />
</div>
</fieldset>
<fieldset class="outl">
-<legend>{t}Rectangle/polygon{/t}</legend>
+<legend>{t}Rectangle/polygon/circle{/t}</legend>
<div class="outl_block_center">
- {t}outline color{/t}:
- <center>
+ <span class="outl_label" >{t}outline color{/t}:</span>
<div id="outline_polygon_outline_color_d" class="outl_color_block" style="{if $outline_polygon_outline_color_selected != ''}background-color:{$outline_polygon_outline_color_selected};{/if}" onclick="javascript:toolPicker('1','outline_polygon_outline_color');" ></div>
- </center>
- <input type="text" id="outline_polygon_outline_color" name="outline_polygon_outline_color" size="7" value="{$outline_polygon_outline_color_selected}" />
+ <input type="text" id="outline_polygon_outline_color" name="outline_polygon_outline_color" size="7" class="outl_color_hex" value="{$outline_polygon_outline_color_selected}" />
</div>
<div class="outl_block_center">
- {t}background color{/t}:
- <center>
+ <span class="outl_label" >{t}background color{/t}:</span>
<div id="outline_polygon_background_color_d" class="outl_color_block" style="{if $outline_polygon_background_color_selected != ''}background-color:{$outline_polygon_background_color_selected};{/if}" onclick="javascript:toolPicker('1','outline_polygon_background_color');" ></div>
- </center>
- <input type="text" id="outline_polygon_background_color" name="outline_polygon_background_color" size="7" value="{$outline_polygon_background_color_selected}" />
+ <input type="text" id="outline_polygon_background_color" name="outline_polygon_background_color" size="7" class="outl_color_hex" value="{$outline_polygon_background_color_selected}" />
</div>
<div class="outl_block_center">
- {t}transparency{/t}:<br />
+ <span class="outl_label" >{t}transparency{/t}:</span>
<input type="text" id="outline_polygon_transparency" name="outline_polygon_transparency" size="3" value="{$outline_polygon_transparency_selected}" />
</div>
+
+</fieldset>
+
+<fieldset class="outl">
+<legend>{t}Circle{/t}</legend>
+
+<div class="outl_block_center">
+ {t}To draw a circle, either clic&drag on the map or set a value for the radius and clic on the map.{/t}<br />
+ <span class="outl_label" >{t}circle radius{/t}:</span>
+ <input type="text" id="outline_circle_radius" name="outline_circle_radius" size="5" value="{$outline_circle_radius}" />
+</div>
+
</fieldset>
{t}Total area{/t}: {$outline_area}<br />
Index: plugins/outline/templates/outlinelabel.tpl
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/plugins/outline/templates/outlinelabel.tpl,v
retrieving revision 1.10
diff -u -r1.10 outlinelabel.tpl
--- plugins/outline/templates/outlinelabel.tpl 16 Mar 2006 14:52:57 -0000 1.10
+++ plugins/outline/templates/outlinelabel.tpl 8 Feb 2008 08:06:29 -0000
@@ -5,6 +5,7 @@
var polyDefaultLabel = '{t}polygon label{/t}';
var rectangleDefaultLabel = '{t}rectangle label{/t}';
var pointDefaultLabel = '{t}point label{/t}';
+ var circleDefaultLabel = '{t}circle label{/t}';
/*]]>*/
</script>
<div id="outlineLabelInputDiv">
Index: po/client.fr.po
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/po/client.fr.po,v
retrieving revision 1.23
diff -u -r1.23 client.fr.po
--- po/client.fr.po 13 Jul 2007 06:53:44 -0000 1.23
+++ po/client.fr.po 8 Feb 2008 09:02:07 -0000
@@ -484,6 +484,14 @@
msgstr "Couleur surface"
#: plugins/outline/templates/outline.tpl
+msgid "To draw a circle, either clic&drag on the map or set a value for the radius and clic on the map."
+msgstr "Pour dessiner un cercle, soit cliquez/déplacez le curseur sur la carte, soit spécifiez un rayon et cliquez sur la carte."
+
+#: plugins/outline/templates/outline.tpl
+msgid "circle radius"
+msgstr "Rayon du cercle"
+
+#: plugins/outline/templates/outline.tpl
msgid "Total area"
msgstr "Surface totale"
@@ -492,6 +500,10 @@
msgstr "Effacer les dessins"
#: plugins/outline/templates/outlinelabel.tpl
+msgid "circle label"
+msgstr "titre du cercle"
+
+#: plugins/outline/templates/outlinelabel.tpl
msgid "line label"
msgstr "titre de la ligne"
@@ -512,6 +524,14 @@
msgstr "votre titre"
#: plugins/outline/templates/outlinelabel.tpl
+msgid "Rectangle/polygon/circle"
+msgstr "Rectangle/polygone/cercle"
+
+#: plugins/outline/templates/outlinelabel.tpl
+msgid "Circle"
+msgstr "Cercle"
+
+#: plugins/outline/templates/outlinelabel.tpl
msgid "ok"
msgstr "OK"
More information about the Cartoweb-users
mailing list