[mapserver-users] On-the-fly field calculation in a GetFeatureInfo request
Passmore, James H.
jpass at bgs.ac.uk
Fri Mar 17 03:38:41 PDT 2017
As an example of JavaScript in a GetFeatureInfo response, I can show you:
http://ogc.bgs.ac.uk/cgi-bin/TFL-PSI/ows?language=eng&REQUEST=GetFeatureInfo&SERVICE=WMS&VERSION=1.3.0&LAYERS=GBR_Stoke-on-Trent_ESA_EN_5k_psi_TS&STYLES=&FORMAT=image/png&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&CRS=EPSG:4326&BBOX=53.0052235378464,-2.28573545848794,53.1251768672774,-2.13175281574312&WIDTH=1086&HEIGHT=846&QUERY_LAYERS=GBR_Stoke-on-Trent_ESA_EN_5k_psi_TS&i=337&j=255&info_format=text/html&
The chart that shows is plotted by JavaScript in the response according to values retrieved.
View source to see the JavaScript as created.
The relevant parts of the template here are:
Creating the structure we want to plot
<script type="text/javascript"><!--
var [Id]_tsline=[['1992-05-11',[D19920511]],['1993-01-11',[D19930111]],['1993-02-15',[D19930215]],['1993-03-22',[D19930322]],['1993-05-31',[D19930531]],['1993-08-09',[D19930809]],['1993-10-18',[D19931018]],['1993-11-22',[D19931122]],['1995-04-19',[D19950419]],['1995-05-24',[D19950524]],['1995-05-25',[D19950525]],['1995-06-28',[D19950628]],['1995-06-29',[D19950629]],['1995-08-02',[D19950802]],['1995-08-03',[D19950803]],['1995-10-11',[D19951011]],['1995-10-12',[D19951012]],['1995-12-21',[D19951221]],['1996-02-28',[D19960228]],['1996-02-29',[D19960229]],['1996-04-03',[D19960403]],['1996-04-04',[D19960404]],['1996-05-08',[D19960508]],['1996-05-09',[D19960509]],['1996-06-12',[D19960612]],['1996-07-17',[D19960717]],['1996-08-22',[D19960822]],['1996-10-31',[D19961031]],['1996-12-05',[D19961205]],['1997-01-09',[D19970109]],['1997-02-13',[D19970213]],['1997-03-20',[D19970320]],['1997-04-24',[D19970424]],['1997-05-29',[D19970529]],['1997-08-07',[D19970807]],['1997-09-11',[D19970911]],['1997-10-16',[D19971016]],['1997-11-20',[D19971120]],['1997-12-25',[D19971225]],['1998-01-29',[D19980129]],['1998-03-05',[D19980305]],['1998-04-09',[D19980409]],['1998-05-14',[D19980514]],['1998-06-18',[D19980618]],['1998-07-23',[D19980723]],['1998-08-27',[D19980827]],['1998-10-01',[D19981001]],['1998-11-05',[D19981105]],['1998-12-10',[D19981210]],['1999-02-18',[D19990218]],['1999-03-25',[D19990325]],['1999-08-12',[D19990812]],['1999-09-15',[D19990915]],['1999-09-16',[D19990916]],['1999-10-20',[D19991020]],['1999-10-21',[D19991021]],['1999-11-25',[D19991125]],['1999-12-30',[D19991230]],['2000-02-03',[D20000203]],['2000-03-09',[D20000309]],['2000-04-13',[D20000413]],['2000-05-18',[D20000518]],['2000-06-22',[D20000622]],['2000-07-27',[D20000727]],['2000-08-31',[D20000831]],['2000-11-09',[D20001109]],['2000-12-14',[D20001214]],['2001-10-25',[D20011025]],['2002-10-10',[D20021010]],['2003-02-27',[D20030227]]]; //-->
</script>
...
Creating a location to put the chart
<tr><td id="[Id]_chart1" class="tschart" title="Time series chart for selected point" style="display:none;"></td></tr>
...
Adding the JavaScript that do the plotting:
<script type="text/javascript"><!--
$("#[Id]_chart1:hidden").show();
var plot1 = $.jqplot('[Id]_chart1', [[Id]_tsline], {
title:'Time series plot for selected point',
axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}},
series:[{lineWidth:3, markerOptions:{style:'circle'}}]
}); // -->
</script>
Hope this helps
James
-----Original Message-----
From: mapserver-users [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of mapserver-users-request at lists.osgeo.org
Sent: 16 March 2017 19:00
To: mapserver-users at lists.osgeo.org
Subject: mapserver-users Digest, Vol 110, Issue 21
Send mapserver-users mailing list submissions to
mapserver-users at lists.osgeo.org
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.osgeo.org/mailman/listinfo/mapserver-users
or, via email, send a message with subject or body 'help' to
mapserver-users-request at lists.osgeo.org
You can reach the person managing the list at
mapserver-users-owner at lists.osgeo.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of mapserver-users digest..."
Today's Topics:
1. On-the-fly field calculation in a GetFeatureInforequest
(Abrabacabra)
2. Re: On-the-fly field calculation in a GetFeatureInfo request
(Jörg Thomsen (WhereGroup))
3. Re: On-the-fly field calculation in a GetFeatureInfo request
(Patrice)
----------------------------------------------------------------------
Message: 1
Date: Wed, 15 Mar 2017 22:25:41 -0400
From: Abrabacabra <abrabacabra at openmailbox.org>
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] On-the-fly field calculation in a
GetFeatureInforequest
Message-ID: <b023d825-7607-e336-69da-25211c7b4bb0 at openmailbox.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Hello,
Is it possible to do numeric calculations with the result of a GetFeatureInfo? Some layers have an area field in square meters but I want to display it to the user in acres or hectares. It would be nice not having to create a second attribute column in my source layer just for that.
I am using an html template at layer level to output the results of the query.
Mapserver 7.0.4
Thank you,
Patrice
------------------------------
Message: 2
Date: Thu, 16 Mar 2017 08:50:35 +0100
From: Jörg Thomsen (WhereGroup) <joerg.thomsen at wheregroup.com>
To: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] On-the-fly field calculation in a
GetFeatureInfo request
Message-ID: <58cdc3c0-94b4-81cf-2a78-b10e31677541 at wheregroup.com>
Content-Type: text/plain; charset=utf-8
Hello Patrice,
I would prefer to save the data in a database using a view to create the additional field (I haven't tried, but I think even spatialite is possible as mapserver-deatasource?)
Another way would be to use scripting
- calculate the value with javascript within the template-html or
- use server-side processing within the template
Regards, Jörg
Am 16.03.2017 um 03:25 schrieb Abrabacabra:
> Hello,
>
> Is it possible to do numeric calculations with the result of a
> GetFeatureInfo? Some layers have an area field in square meters but I
> want to display it to the user in acres or hectares. It would be nice
> not having to create a second attribute column in my source layer just
> for that.
>
> I am using an html template at layer level to output the results of
> the query.
> Mapserver 7.0.4
>
> Thank you,
>
>
> Patrice
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
Viele Grüße,
Jörg Thomsen
--
*********************************************************
FOSS Academy Winterschule 2017
20.-24.03.2017 in Bonn
Alles Wichtige zur Erstellung einer GDI in nur 5 Tagen!
https://www.foss-academy.com/schulungstermine/kompaktkurs-winterschule
*********************************************************
-------------------------------
Jörg Thomsen
WhereGroup GmbH & Co. KG
Gillweg 3
14193 Berlin
Germany
Fon: +49 (0)30 / 5130 278 74
Fax: +49 (0)30 / 89 09 53 21
joerg.thomsen at wheregroup.com
www.wheregroup.com
Amtsgericht Bonn, HRA 6788
-------------------------------
Komplementärin:
WhereGroup Verwaltungs GmbH
vertreten durch:
Olaf Knopp, Peter Stamm
-------------------------------
Folgen Sie der WhereGroup auf twitter: http://twitter.com/WhereGroup_com
------------------------------
Message: 3
Date: Thu, 16 Mar 2017 13:58:33 -0400
From: Patrice <abrabacabra at openmailbox.org>
To: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] On-the-fly field calculation in a
GetFeatureInfo request
Message-ID: <962d2dab-bf7e-238e-67f3-a935586a3dce at openmailbox.org>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Could you point me in the right direction for the solutions you proposed? I like the idea of do calculations client-side with javascript, however, I didn't figure out how to fetch the value withina <script> tag in the template.
On 2017-03-16 03:50, Jörg Thomsen (WhereGroup) wrote:
> Hello Patrice,
>
> I would prefer to save the data in a database using a view to create
> the additional field (I haven't tried, but I think even spatialite is
> possible as mapserver-deatasource?)
>
> Another way would be to use scripting
> - calculate the value with javascript within the template-html or
> - use server-side processing within the template
>
> Regards, Jörg
>
> Am 16.03.2017 um 03:25 schrieb Abrabacabra:
>> Hello,
>>
>> Is it possible to do numeric calculations with the result of a
>> GetFeatureInfo? Some layers have an area field in square meters but I
>> want to display it to the user in acres or hectares. It would be nice
>> not having to create a second attribute column in my source layer
>> just for that.
>>
>> I am using an html template at layer level to output the results of
>> the query.
>> Mapserver 7.0.4
>>
>> Thank you,
>>
>>
>> Patrice
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>
> Viele Grüße,
> Jörg Thomsen
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20170316/991abb32/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users
------------------------------
End of mapserver-users Digest, Vol 110, Issue 21
************************************************
________________________________
This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.
________________________________
More information about the MapServer-users
mailing list