Geolicious / qgis2leaf

A QGIS plugin to create a working leaflet based webmap from it
127 stars 30 forks source link

cluster not working in 2.6 #132

Closed LucaMoiana closed 9 years ago

LucaMoiana commented 9 years ago

Hi great plugin,

with 2.4 everything was fine, but, since I updated to 2.6, the make cluster option ain't working.

thanks again for this great plugin

riccardoklinger commented 9 years ago

You're right. Saw this behavior in my tests as well :-(

Von meinem iPhone gesendet

Am 25.11.2014 um 23:48 schrieb Luca Moiana notifications@github.com:

Hi great plugin,

with 2.4 everything was fine, but, since I updated to 2.6, the make cluster option ain't working.

thanks again for this great plugin

— Reply to this email directly or view it on GitHub.

LucaMoiana commented 9 years ago

can that be related with Autolinker? just a thought.

tomchadwin commented 9 years ago

Any error messages?

LucaMoiana commented 9 years ago

Not really, but working on another project, I noticed that, removing autolinker, made the cluster plugin work. Consider I still a noob.

riccardoklinger commented 9 years ago

nothing! tested it without the autolinker. no success. Freaky...


Geolicious GbR Agentur für Geo-Kommunikation

Riccardo Klinger Geschäftsführer

mobil: 0176 63437298 e-mail: riccardo.klinger@geolicious.de web: www.geolicious.de

Geolicious GbR c/o Daniel Kerkow Binzstraße 48 13189 Berlin

Gesellschafter: Riccardo Klinger Daniel Kerkow Jakob Hafner

Sitz der Gesellschaft: Berlin Ust-ID: DE289107523

On Wed, Nov 26, 2014 at 10:51 AM, Tom Chadwin notifications@github.com wrote:

Any error messages?

On 26 Nov 2014, at 07:22, Luca Moiana <notifications@github.com<mailto: notifications@github.com>> wrote:

can that be related with Autolinker? just a thought.

— Reply to this email directly or view it on GitHub< https://github.com/Geolicious/qgis2leaf/issues/132#issuecomment-64524103>.

Tom Chadwin, UK National Parks Portal Manager Telephone: 01434 611511 Mob: 07881 109617 Web: www.northumberlandnationalpark.org.uk< http://www.northumberlandnationalpark.org.uk/>

IMPORTANT NOTICE - Disclaimer - This communication is from Northumberland National Park Authority (NNPA).The Authority’s head office and principal place of business is Eastburn, South Park, Hexham, Northumberland, NE46 1BS, United Kingdom. If you are not the intended recipient(s) please note that any form of disclosure, distribution, copying or use of this communication or the information in it or in any attachments is strictly prohibited and may be unlawful. If you have received this communication in error, please delete the email and destroy any copies of it. Any views or opinions presented are solely those of the author and do not necessarily represent those of NNPA.Contractors or potential contractors are reminded that a formal Order or Contract is needed for NNPA to be bound by any offer or acceptance of terms for the supply of goods or services Although this email and any attachments are believed to be free of any virus or other defects which might affect any computer or IT system into which they are received, no responsibility is accepted by the NNPA for any loss or damage arising in any way from the receipt or use thereof. Computer systems of this Authority may be monitored and communications carried out on them recorded, to secure the effective operation of the system and for other lawful purpose.

— Reply to this email directly or view it on GitHub https://github.com/Geolicious/qgis2leaf/issues/132#issuecomment-64539021 .

tomchadwin commented 9 years ago

OK, here's what I see in 2.6:

When it fails in the second case, there is the following JS error:

'cluster_[LAYERNAME]JSON' is undefined

I'll try to look into it.

tomchadwin commented 9 years ago

Correction - error is:

'cluster_group[LAYERNAME]JSON' is undefined

tomchadwin commented 9 years ago

I've found a difference in the way 2.4 and 2.6 encode to JSON (I think when we use qgis.core.QgsVectorFileWriter.writeAsVectorFormat()). 2.4 uses the geometry type "Point", with a pair of coordinates, while 2.6 uses "Multipoint" with an array of points:

{ "type": "Feature", "properties": { "color_qgis2leaf": '#88cce4', "radius_qgis2leaf": 4.0, "transp_qgis2leaf": 1.0, "transp_fill_qgis2leaf": 1.0, "osm_id": 49717206.000000, "name": "Großkarolinenfeld", "type": "village", "population": 6894 }, "geometry": { "type": "Point", "coordinates": [ 12.0801467, 47.8912213 ] } },
{ "type": "Feature", "properties": { "color_qgis2leaf": '#e6576d', "radius_qgis2leaf": 4.0, "transp_qgis2leaf": 1.0, "transp_fill_qgis2leaf": 1.0, "osm_id": 49717206.000000, "name": "Großkarolinenfeld", "type": "village", "population": 6894 }, "geometry": { "type": "MultiPoint", "coordinates": [ [ 12.0801467, 47.8912213 ] ] } },

I'll see if I can find any documentation of the change. Can anyone else shed any light on this, or help?

riccardoklinger commented 9 years ago

My thoughts were heading In the same direction. I'll check tomorrow night if I'll find a quick fix.

Von meinem iPhone gesendet

Am 26.11.2014 um 22:39 schrieb Tom Chadwin notifications@github.com:

I've found a difference in the way 2.4 and 2.6 encode to JSON (I think when we use qgis.core.QgsVectorFileWriter.writeAsVectorFormat()). 2.4 uses the geometry type "Point", with a pair of coordinates, while 2.6 uses "Multipoint" with an array of points:

{ "type": "Feature", "properties": { "color_qgis2leaf": '#88cce4', "radius_qgis2leaf": 4.0, "transp_qgis2leaf": 1.0, "transp_fill_qgis2leaf": 1.0, "osm_id": 49717206.000000, "name": "Großkarolinenfeld", "type": "village", "population": 6894 }, "geometry": { "type": "Point", "coordinates": [ 12.0801467, 47.8912213 ] } }, { "type": "Feature", "properties": { "color_qgis2leaf": '#e6576d', "radius_qgis2leaf": 4.0, "transp_qgis2leaf": 1.0, "transp_fill_qgis2leaf": 1.0, "osm_id": 49717206.000000, "name": "Großkarolinenfeld", "type": "village", "population": 6894 }, "geometry": { "type": "MultiPoint", "coordinates": [ [ 12.0801467, 47.8912213 ] ] } }, I'll see if I can find any documentation of the change. Can anyone else shed any light on this, or help?

— Reply to this email directly or view it on GitHub.

tomchadwin commented 9 years ago

Follow-ups in other places:

http://osgeo-org.1560.x6.nabble.com/QgsVectorFileWriter-writeAsVectorFormat-created-geoJSON-Points-in-2-4-now-Multipoints-in-2-6-td5175181.html https://github.com/Leaflet/Leaflet.markercluster/issues/425

marcobra commented 9 years ago

Seem related to this: http://hub.qgis.org/issues/11542

Ciao

2014-11-26 23:18 GMT+01:00 Tom Chadwin notifications@github.com:

Follow-ups in other places:

http://osgeo-org.1560.x6.nabble.com/QgsVectorFileWriter-writeAsVectorFormat-created-geoJSON-Points-in-2-4-now-Multipoints-in-2-6-td5175181.html Leaflet/Leaflet.markercluster#425 https://github.com/Leaflet/Leaflet.markercluster/issues/425

— Reply to this email directly or view it on GitHub https://github.com/Geolicious/qgis2leaf/issues/132#issuecomment-64718907 .

Linux Infinite Freedom

I'm writing from this place: http://www.openstreetmap.org/?lat=44.39945&lon=8.6798&zoom=15&layers=M

riccardoklinger commented 9 years ago

agree ion this! Still no clue, whether we can save it as we use the included functionality to save as json and not the OGR2OGR. shall we switch to ogr2ogr?!

Best, riccardo


Geolicious GbR Agentur für Geo-Kommunikation

Riccardo Klinger Geschäftsführer

mobil: 0176 63437298 e-mail: riccardo.klinger@geolicious.de web: www.geolicious.de

Geolicious GbR c/o Daniel Kerkow Binzstraße 48 13189 Berlin

Gesellschafter: Riccardo Klinger Daniel Kerkow Jakob Hafner

Sitz der Gesellschaft: Berlin Ust-ID: DE289107523

On Thu, Nov 27, 2014 at 9:52 AM, marcobra notifications@github.com wrote:

Seem related to this: http://hub.qgis.org/issues/11542

Ciao

2014-11-26 23:18 GMT+01:00 Tom Chadwin notifications@github.com:

Follow-ups in other places:

http://osgeo-org.1560.x6.nabble.com/QgsVectorFileWriter-writeAsVectorFormat-created-geoJSON-Points-in-2-4-now-Multipoints-in-2-6-td5175181.html Leaflet/Leaflet.markercluster#425 https://github.com/Leaflet/Leaflet.markercluster/issues/425

— Reply to this email directly or view it on GitHub < https://github.com/Geolicious/qgis2leaf/issues/132#issuecomment-64718907> .

Linux Infinite Freedom

I'm writing from this place: http://www.openstreetmap.org/?lat=44.39945&lon=8.6798&zoom=15&layers=M

— Reply to this email directly or view it on GitHub https://github.com/Geolicious/qgis2leaf/issues/132#issuecomment-64761305 .

mtravis commented 9 years ago

I think it would be best to move to ogr2ogr as it future proofs against major qgis api changes

tomchadwin commented 9 years ago

Markercluster's @danzel suggested that this might be because Leaflet turns geoJSON multipoints into FeatureGroups, and he is right:

case 'MultiPoint': 
    for (i = 0, len = coords.length; i < len; i++) { 
        latlng = coordsToLatLng(coords[i]); 
        layers.push(pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng)); 
    } 
    return new L.FeatureGroup(layers); 

(https://github.com/Leaflet/Leaflet/blob/master/src/layer/GeoJSON.js)

This therefore won't work as things stand. @ricckli and @mtravis's suggestion of switching to ogr2ogr is definitely worth investigating. @ricckli, might this also allow other things, like the reducing resolution which the QGIS API did not allow?

ghost commented 9 years ago

hi tom, yes, this can be done with ogr2ogr. but I am not sure whether there was a problem in determining the correct ogr2ogr path on the system to call the command...


"The best model for a cat is another, or preferably the same cat"

Riccardo Klinger

digital-geography.com geolicious.de

cell: 0049-176-63437298

2014-11-27 13:21 GMT+01:00 Tom Chadwin notifications@github.com:

Markercluster's @danzel https://github.com/danzel suggested that this might be because Leaflet turns geoJSON multipoints into FeatureGroups, and he is right:

case 'MultiPoint': for (i = 0, len = coords.length; i < len; i++) { latlng = coordsToLatLng(coords[i]); layers.push(pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng)); } return new L.FeatureGroup(layers);

(https://github.com/Leaflet/Leaflet/blob/master/src/layer/GeoJSON.js)

This therefore won't work as things stand. @ricckli https://github.com/ricckli and @mtravis https://github.com/mtravis's suggestion of switching to ogr2ogr is definitely worth investigating. @ricckli https://github.com/ricckli, might this also allow other things, like the reducing resolution which the QGIS API did not allow?

— Reply to this email directly or view it on GitHub https://github.com/Geolicious/qgis2leaf/issues/132#issuecomment-64783807 .

tomchadwin commented 9 years ago

Looks like a patch is available for QGIS, and I presume it will be rolled into 2.7:

https://hub.qgis.org/projects/quantum-gis/repository/revisions/11c2bae74079ab008d7e7fb9233d714409aff008/diff/src/core/qgsvectorfilewriter.cpp

I could look at a hack to change the text of the encoded GeoJSON from multipoint to point, but:

My feeling, since the basic display of points is not broken, only clustering, that we should leave it, and wait for 2.7. I suppose we could get the GUI not to allow clustering if the QGIS version is 2.6.

As for migrating to ogr2ogr, I leave that decision to others - I've no experience of the tool myself, so I'm no judge.

tomchadwin commented 9 years ago

Has anyone looked at this since 2.8 was released? Is clustering still failing?

LucaMoiana commented 9 years ago

Looks to me that cluster is working on 2.8. L

On 30/mar/2015, at 12:02, Tom Chadwin notifications@github.com wrote:

Has anyone looked at this since 2.8 was released? Is clustering still failing?

— Reply to this email directly or view it on GitHub.

tomchadwin commented 9 years ago

It's broken in master at the mo, but I think I have a fix.

tomchadwin commented 9 years ago

Fixed #246