Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Join our "Ask Me About" community webinar on May 20th at 9 AM CET and 5 PM CET to explore cybersecurity and monitoring for Data Center and edge IT. Learn about market trends, cutting-edge technologies, and best practices from industry experts.
Register and secure your Critical IT infrastructure

Complex map location display requirements

EcoStruxure Geo SCADA Expert Forum

Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • Remote Operations
  • EcoStruxure Geo SCADA Expert Forum
  • Complex map location display requirements
Options
  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
sbeadle
Kirk sbeadle Kirk
307
AndrewScott
Admiral AndrewScott
95
BevanWeiss
Spock BevanWeiss
89
AdamWoodlandToo
Lt. Commander AdamWoodlandToo
36
View All
Related Products
product field
Schneider Electric
EcoStruxure™ Geo SCADA Expert

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to EcoStruxure Geo SCADA Expert Forum
Solved
sbeadle
Kirk sbeadle Kirk
Kirk

Posted: ‎2024-01-16 11:05 PM

0 Likes
2
1144
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-01-16 11:05 PM

Complex map location display requirements

Hi All,

I recently had some complex mapping requirements and I thought I'd share them here, then answer my own question!

I have a device which reports its location using a GPS source, and the Latitude, Longitude and Speed in three Analog points, in the Historic data. I want to show the location history on a map:

* Map markers each time the location changes

* Colour them by the age of the location data, e.g. green, through yellow to red (up to 2 days)

* Show the age in hours by the text label

* Show a tooltip with the sample time, speed etc

The key difference here with the main use of SQL for maps is that the location is not in the usual database columns.

I'll follow up this post with the answer I came up with!

Labels
  • Labels:
  • IoT
  • Tags:
  • english
  • scada
  • SCADA app
  • SCADA software
  • SCADA tutorial
  • Telemetry and SCADA
Reply

Link copied. Please paste this link to share this article on your social media post.

  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
sbeadle
Kirk sbeadle Kirk
Kirk

Posted: ‎2024-01-16 11:29 PM

In response to sbeadle
0 Likes
0
1142
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-01-16 11:29 PM

Here's the whole query, and a snip of the result:

select * from (
SELECT
D.FULLNAME as "FullName", LAH.VALUEASREAL as "GISLOCATION->LATITUDE", LOH.VALUEASREAL as "GISLOCATION->LONGITUDE",
0 as "Background",
case when { FN TIMESTAMPDIFF( SQL_TSI_MINUTE, LAH.RecordTime, {OPC 'NOW'}) } < 1440
then (cast(cast({ FN TIMESTAMPDIFF( SQL_TSI_MINUTE, LAH.RecordTime, {OPC 'NOW'}) } as REAL)/1440*255 as INT) + 255*256)
else (255 + cast( (2880-cast({ FN TIMESTAMPDIFF( SQL_TSI_MINUTE, LAH.RecordTime, {OPC 'NOW'}) } AS REAL) )/1440*255 as INT)*256)
end as "Foreground",
0 as "Blink",
'Device: ' || D.ParentGroupName || '<BR>' ||
'Time: ' || FormatValue( LAH.RECORDTIME Using 'dd-MMM-yyyy HH:mm') ||'<BR>' ||
'Speed: ' || FormatValue( coalesce(LSH.VALUEASREAL,0) Using '##') || 'kmh' AS "TOOLTIP",
'-' || FormatValue({ FN TIMESTAMPDIFF( SQL_TSI_HOUR, LAH.RecordTime, {OPC 'NOW'}) } using '#') || 'h' as "MarkerText",
'triangledown' as "MarkerShape",
LAH.RecordTime as TIM
FROM
CMQTTTEXTDEVICE AS D
LEFT JOIN CMQTTTEXTPOINTANALOG AS LA ON ( LA.DEVICEID = D.ID AND LA.NAME = 'Loc lat' )
LEFT JOIN CMQTTTEXTPOINTANALOG AS LO ON ( LO.DEVICEID = D.ID AND LO.NAME = 'Loc long' )
LEFT JOIN CMQTTTEXTPOINTANALOG AS LS ON ( LS.DEVICEID = D.ID AND LS.NAME = 'GPS Speed' )
LEFT JOIN CDBHISTORIC AS LAH ON ( LAH.ID = LA.ID AND LAH.RECORDTIME BETWEEN { OPC 'Hour - 48 Hours' } AND { OPC 'M' } )
LEFT JOIN CDBHISTORIC AS LOH ON ( LOH.ID = LO.ID AND LOH.RECORDTIME BETWEEN { OPC 'Hour - 48 Hours' } AND { OPC 'M' } )
LEFT JOIN CDBHISTORIC AS LSH ON ( LSH.ID = LS.ID AND LSH.RECORDTIME BETWEEN { OPC 'Hour - 48 Hours' } AND { OPC 'M' } )
WHERE
D.FULLNAME = 'Devices.one.Device' AND LAH.RECORDTIME = LOH.RECORDTIME AND LAH.RECORDTIME = LSH.RECORDTIME AND LAH.VALUEASREAL <> 0 AND LOH.VALUEASREAL <> 0
)
ORDER BY
TIM ASC

sbeadle_0-1705476531027.png

Thank you! I hope this was interesting - feel free to reply with comments.

Steve

 

See Answer In Context

Reply

Link copied. Please paste this link to share this article on your social media post.

Replies 2
sbeadle
Kirk sbeadle Kirk
Kirk

Posted: ‎2024-01-16 11:26 PM

0 Likes
1
1142
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-01-16 11:26 PM

I'll break the query down, starting with the tables:

FROM
CMQTTTEXTDEVICE AS D

This is the table containing the RTU - it could be DNP3 or something else!

LEFT JOIN CMQTTTEXTPOINTANALOG AS LA ON ( LA.DEVICEID = D.ID AND LA.NAME = 'Loc lat' )
LEFT JOIN CMQTTTEXTPOINTANALOG AS LO ON ( LO.DEVICEID = D.ID AND LO.NAME = 'Loc long' )
LEFT JOIN CMQTTTEXTPOINTANALOG AS LS ON ( LS.DEVICEID = D.ID AND LS.NAME = 'GPS Speed' )

Here are links to my three points from that device, with their names.

LEFT JOIN CDBHISTORIC AS LAH ON ( LAH.ID = LA.ID AND LAH.RECORDTIME BETWEEN { OPC 'Hour - 48 Hours' } AND { OPC 'M' } )
LEFT JOIN CDBHISTORIC AS LOH ON ( LOH.ID = LO.ID AND LOH.RECORDTIME BETWEEN { OPC 'Hour - 48 Hours' } AND { OPC 'M' } )
LEFT JOIN CDBHISTORIC AS LSH ON ( LSH.ID = LS.ID AND LSH.RECORDTIME BETWEEN { OPC 'Hour - 48 Hours' } AND { OPC 'M' } )

And I need to join with historic data for each point. Each one needs the same time constraint.

WHERE
D.FULLNAME = 'Devices.one.Device' AND LAH.RECORDTIME = LOH.RECORDTIME AND LAH.RECORDTIME = LSH.RECORDTIME AND LAH.VALUEASREAL <> 0 AND LOH.VALUEASREAL <> 0

The where clause picks up the specific device I want to map, and 'connects' the historic data in the three points into a single record per time value. Note that this ONLY works when each time value is exactly the same for a reading of Lat, Long and Speed. If this is not the case then you'd need to use a Historic View table instead of the CDBHISTORIC database table. My device also occasionally has a bad location read from GPS and outputs zeroes, so I want to exclude those too.

SELECT
D.FULLNAME as "FullName", LAH.VALUEASREAL as "GISLOCATION->LATITUDE", LOH.VALUEASREAL as "GISLOCATION->LONGITUDE",

This part of the select query gets the main location data. It also gets the device FullName which drives the pick action.

0 as "Background",
case when { FN TIMESTAMPDIFF( SQL_TSI_MINUTE, LAH.RecordTime, {OPC 'NOW'}) } < 1440
 then (cast(cast({ FN TIMESTAMPDIFF( SQL_TSI_MINUTE, LAH.RecordTime, {OPC 'NOW'}) } as REAL)/1440*255 as INT) + 255*256)
else (255 + cast( (2880-cast({ FN TIMESTAMPDIFF( SQL_TSI_MINUTE, LAH.RecordTime, {OPC 'NOW'}) } AS REAL) )/1440*255 as INT)*256)
end as "Foreground",
0 as "Blink",

This sets the RGB foreground colour of the symbol, using the timestamp 'age' to set a colour range over the two day time period.

'Device: ' || D.ParentGroupName || '<BR>' ||
'Time: ' || FormatValue( LAH.RECORDTIME Using 'dd-MMM-yyyy HH:mm') ||'<BR>' ||
'Speed: ' || FormatValue( coalesce(LSH.VALUEASREAL,0) Using '##') || 'kmh' AS "TOOLTIP",
'-' || FormatValue({ FN TIMESTAMPDIFF( SQL_TSI_HOUR, LAH.RecordTime, {OPC 'NOW'}) } using '#') || 'h' as "MarkerText",

A tooltip label will show the device name, time, speed/units. The marker text calculates the age in hours.

'triangledown' as "MarkerShape",
LAH.RecordTime as TIM

Finally, select the marker's shape. I want to show newer items 'on top' of older ones, so I need a time column to sort on later.

select * from (
SELECT {everything else}
)
ORDER BY
TIM ASC

And the whole query must be 'wrapped' in a nested select. This is because we need to 'tell' the query display system we are not using the usual location data fields, and the 'meta' fields can't be used to filter query data by the rectangular displayed map extent.

The Order By clause ensures that the oldest items are plotted first, so newer ones are on the top.

Next Reply - the whole query!

 

 

Reply

Link copied. Please paste this link to share this article on your social media post.

sbeadle
Kirk sbeadle Kirk
Kirk

Posted: ‎2024-01-16 11:29 PM

In response to sbeadle
0 Likes
0
1143
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-01-16 11:29 PM

Here's the whole query, and a snip of the result:

select * from (
SELECT
D.FULLNAME as "FullName", LAH.VALUEASREAL as "GISLOCATION->LATITUDE", LOH.VALUEASREAL as "GISLOCATION->LONGITUDE",
0 as "Background",
case when { FN TIMESTAMPDIFF( SQL_TSI_MINUTE, LAH.RecordTime, {OPC 'NOW'}) } < 1440
then (cast(cast({ FN TIMESTAMPDIFF( SQL_TSI_MINUTE, LAH.RecordTime, {OPC 'NOW'}) } as REAL)/1440*255 as INT) + 255*256)
else (255 + cast( (2880-cast({ FN TIMESTAMPDIFF( SQL_TSI_MINUTE, LAH.RecordTime, {OPC 'NOW'}) } AS REAL) )/1440*255 as INT)*256)
end as "Foreground",
0 as "Blink",
'Device: ' || D.ParentGroupName || '<BR>' ||
'Time: ' || FormatValue( LAH.RECORDTIME Using 'dd-MMM-yyyy HH:mm') ||'<BR>' ||
'Speed: ' || FormatValue( coalesce(LSH.VALUEASREAL,0) Using '##') || 'kmh' AS "TOOLTIP",
'-' || FormatValue({ FN TIMESTAMPDIFF( SQL_TSI_HOUR, LAH.RecordTime, {OPC 'NOW'}) } using '#') || 'h' as "MarkerText",
'triangledown' as "MarkerShape",
LAH.RecordTime as TIM
FROM
CMQTTTEXTDEVICE AS D
LEFT JOIN CMQTTTEXTPOINTANALOG AS LA ON ( LA.DEVICEID = D.ID AND LA.NAME = 'Loc lat' )
LEFT JOIN CMQTTTEXTPOINTANALOG AS LO ON ( LO.DEVICEID = D.ID AND LO.NAME = 'Loc long' )
LEFT JOIN CMQTTTEXTPOINTANALOG AS LS ON ( LS.DEVICEID = D.ID AND LS.NAME = 'GPS Speed' )
LEFT JOIN CDBHISTORIC AS LAH ON ( LAH.ID = LA.ID AND LAH.RECORDTIME BETWEEN { OPC 'Hour - 48 Hours' } AND { OPC 'M' } )
LEFT JOIN CDBHISTORIC AS LOH ON ( LOH.ID = LO.ID AND LOH.RECORDTIME BETWEEN { OPC 'Hour - 48 Hours' } AND { OPC 'M' } )
LEFT JOIN CDBHISTORIC AS LSH ON ( LSH.ID = LS.ID AND LSH.RECORDTIME BETWEEN { OPC 'Hour - 48 Hours' } AND { OPC 'M' } )
WHERE
D.FULLNAME = 'Devices.one.Device' AND LAH.RECORDTIME = LOH.RECORDTIME AND LAH.RECORDTIME = LSH.RECORDTIME AND LAH.VALUEASREAL <> 0 AND LOH.VALUEASREAL <> 0
)
ORDER BY
TIM ASC

sbeadle_0-1705476531027.png

Thank you! I hope this was interesting - feel free to reply with comments.

Steve

 

Reply

Link copied. Please paste this link to share this article on your social media post.

Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of