[Mapbender-users] Mapbender3: Change digitizing
Dr. Kai Behncke
info at blumige-landschaften.de
Mon Apr 11 20:55:18 PDT 2016
Hi you all,
we found a solution for that, well not a very nice one, because of no
knowledge of symfony, the code is "hot-chaos", but it works:
In:
mapbender3/vendor/mapbender/digitizer/Mapbender/DigitizerBundle/Element/Digitizer.php
From line 169:
169 public function httpAction($action)
170 {
171 /**
172 * @var $requestService Request
173 */
174 $der_nutzername=$this->container->get('request');
175
176
177 if ((substr_count($der_nutzername,'anwender=')==1) AND
(substr_count($der_nu tzername,'@')==1)) {
178
179
180 $der_nutzername_array = explode ('anwender=', $der_nutzername );
181 $der_nutzername=$der_nutzername_array[1];
182
183 $der_nutzername=trim($der_nutzername);
184 $der_nutzername_array2=explode ('@',$der_nutzername);
185 $der_nutzername=$der_nutzername_array2[0];
186 $der_nutzername=str_replace(" ","",$der_nutzername);
187 $der_nutzername="digiowner='".$der_nutzername."'";
188 $der_nutzername=trim($der_nutzername);
189 $der_nutzername=str_replace(" ","",$der_nutzername);
190 // $der_nutzername="nnn".$der_nutzername->get('Referer');
191 }
192 else {
193
194 $der_nutzername="digiowner='xxxxx'";
195 }
....
......
(This is to get the user of a request; for that, in the digitite-table
(e.g. "poi" a column "digiowner" is important)
In
mapbender3/vendor/mapbender/digitizer/Mapbender/DigitizerBundle/Entity/FeatureType.php
In line 396:
public function search(array $criteria = array(),$neue_variable)
{
// In $neue_variable a username is transported
422: $where=$neue_variable;
423 if($where){
424 $queryBuilder->andWhere($where);
425 }
And: in
mapbender/digitizer/Mapbender/DigitizerBundle/Resources/public/mapbender.element.digitizer.js
Line 1305: var the_request=JSON.stringify(request);
1306 the_request+=""
...
.....
1315 if (uri=="save"){
1316
1317
the_request=the_request.replace('}',',"digiowner":"'+der_nutzername+'"}');
....
........
A changed request is build so a geometry belongs to a specific user...
So if someone calls:
http://www.blumige-landschaft.de/mapbender3/application/Blumige-Landschaften
he can`t insert entries.
If one calls:
http://www.blumige-landschaft.de/mapbender3/application/Blumige-Landschaften?anwender=blablablabla
he can.
I know, it`s not a "save"-procedure at all, but enough for the purposes
of that project :-)
the project is: http://blumige-landschaften.de
A databse-trigger sets area and time of an entry
CREATE OR REPLACE FUNCTION datum_einspielen()
RETURNS trigger AS
$BODY$
DECLARE
the_id integer;
abfrage1 text;
BEGIN
the_id:=max(gid) as gid from poi;
abfrage1:='UPDATE poi SET date_favorite=TO_CHAR(CURRENT_DATE,
''DD.MM.YYYY'') WHERE gid='||the_id;
EXECUTE abfrage1;
RAISE NOTICE 'Here we go........%',the_id;
RETURN NULL;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER Trigger_after_poi_entry
AFTER INSERT on poi
FOR EACH ROW
EXECUTE PROCEDURE datum_einspielen();
CREATE OR REPLACE FUNCTION give_me_area_and_date()
RETURNS trigger AS
$BODY$
DECLARE
the_id integer;
the_area numeric;
abfrage1 text;
abfrage2 text;
block text;
BEGIN
the_id:=max(gid) as gid from polygons;
the_area:=round(cast(st_area(st_transform(geom,31467)) as numeric),2)
from polygons where gid=the_id;
abfrage1:='UPDATE polygons SET date_favorite=TO_CHAR(CURRENT_DATE,
''DD.MM.YYYY'') WHERE gid='||the_id;
EXECUTE abfrage1;
abfrage2:='UPDATE polygons SET area='''||the_area||''' WHERE gid='||the_id;
EXECUTE abfrage2;
RETURN NULL;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER Trigger_after_polygon_entry
AFTER INSERT on polygons
FOR EACH ROW
EXECUTE PROCEDURE give_me_area_and_date();
Best regards, Kai
--
---------------------------
Blumige-Landschaften.de
Dr. Kai Behncke
Am Wulberg 15
49324 Melle
Tel.: 0176-84019660 (ab 18.00 Uhr)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapbender_users/attachments/20160412/f7825882/attachment.html>
More information about the Mapbender_users
mailing list