Skip to content

Instantly share code, notes, and snippets.

@paulreimer
Created October 23, 2012 02:05
Show Gist options
  • Save paulreimer/3936258 to your computer and use it in GitHub Desktop.
Save paulreimer/3936258 to your computer and use it in GitHub Desktop.
Select geoJSON string from fix DB
SELECT
CONCAT('{
"type": "LineString",
"coordinates": [',
`linestring`,
'],
"properties": {
"name": ', `quoted_sender`, ',
"popupContent": ', `quoted_sender`,
'}}') as `geoJSON`
FROM (
SELECT
`sender`,
CONCAT('"', `sender`, '"') as `quoted_sender`,
GROUP_CONCAT(CONCAT('[', longitude, ',', latitude, ']')
ORDER BY time ASC SEPARATOR ', ') as `linestring`
FROM `beats`
WHERE sender = 'lunch1'
GROUP BY sender
) as `geometry`;
SELECT
CONCAT('{
"type": "LineString",
"coordinates": [',
`linestring`,
'],
"properties": {
"name": ', `quoted_sender`, ',
"popupContent": ', `quoted_sender`,
'}}') as `geoJSON`
FROM (
SELECT
`sender`,
CONCAT('"', `sender`, '"') as `quoted_sender`,
GROUP_CONCAT(CONCAT('[', longitude, ',', latitude, ']')
ORDER BY time ASC SEPARATOR ', ') as `linestring`
FROM `beats`
WHERE sender = 'lunch1'
GROUP BY sender
) as `geometry`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment