geojson support

Topics: SharpMap v0.9 / v1.x
Developer
Sep 19, 2011 at 4:07 PM

I'd like to add GeoJSON support in SharpMap. 

What I need is something like GeoJSON support in GeoServer's WMS, i.e. when, during a GetMap request, FORMAT is set to "text/json", layer data is returned in this format.

I don't have right now a clear plan of what I do to make this possible (maybe add a new Renderer?) so before digging into source code I ask the community for some suggestions. Anyone have tried this stuff or have some plans about how to do this?

Thanks :)

Coordinator
Sep 19, 2011 at 6:38 PM

Hi,

I'm actually currently planning on writing a new frontend (SharpMapServer) that exposes a WMS server interface and som admin pages. Of course geoJSON and WFS output are other formats that should be supported.

Maybe we should handle vector output formats via some kind of converter-interface that takes a FeatureDataSet and transforms it to the correct output-format?

//Peter

Coordinator
Sep 20, 2011 at 7:15 AM

As a source of inspiration

http://code.google.com/p/sharpmapv2/source/browse/#svn%2Ftrunk%2FSharpMap.Rendering%2FGeoJSON

Hth FObermaier

Developer
Sep 20, 2011 at 7:30 AM

thanks I can start from your ideas

Developer
Sep 20, 2011 at 2:43 PM

I've tried to create a branch but codeplex+svn is completely unusable :(

http://sharpmap.codeplex.com/SourceControl/changeset/changes/92804

even restoring the branch with commit of the midding code returns an error, sorry.

If someone is able to delete the branch (if I try, another error...) please delete it, 'cause the branch is in an invalid status.

Sorry

Coordinator
Sep 20, 2011 at 2:44 PM

I had the same problem some days ago.. I had to do a fresh checkout and then apply changes and then commit to be able to commit at all.

Developer
Sep 20, 2011 at 3:49 PM

tried but without success :( I'm unable to clean the branch, sorry

Coordinator
Sep 20, 2011 at 4:05 PM

I've had issues the other day, too. It boiled down to some incorrect casing. You may want to switch to

https://sharpmap.svn.codeplex.com/svn/Branches/0.9-GeoJSON

If that does not lead to success, I can try to delete it using TeamFoundationServer client

Hth FObermaier

Developer
Sep 20, 2011 at 4:21 PM

Here what I've do:

1) I've modified my copy of the trunk 

2) I've committed my working copy to the branch, without making the switch

The result is that only the modified files were committed to the branch: at work I make operation like this daily, and the branch is always valid, but this time the branch contains only a bunch of files.

3) I've tried to add manually the missing files, but commits failed with error (server doesn't respond well, or something similar)

4) I've tried to delete the branch, receiving an error message

5) I make a fresh checkout and tried to delete the branch... another error :(

If you are able to use TFS delete the branch, maybe using TFS you may be lucky

P.S: today I have some hours to dedicate to the project, wasted fighting againts codeplex... :(

Coordinator
Sep 21, 2011 at 7:35 AM

Sorry Diego, I could not delete the branch. The TFS says it is still branching and there is a lock on it.

Why don't you create a new branch, maybe TFS has finisched branching in a couple of weeks and we can delete it then.

> 2) I've committed my working copy to the branch, without making the switch
I did not know that this is possible with subversion. I've always
- worked on a trunk checkout
- created a new branch from trunk, switched my local copy to that branch
- checked in my changes.

Nonetheless, there seem to arise problems when the casing in the url is mixed up. While it was possible to checkout from e.g. https://sharpmap.svn.codeplex.com/svn/trunk, checking in changes resulted in some obscure error.

> P.S: today I have some hours to dedicate to the project, wasted fighting againts codeplex... :(
That is really bad,

Anybody in favor of a switch to Mercurial?

FObermaier

Developer
Sep 21, 2011 at 7:38 AM
Edited Sep 21, 2011 at 7:39 AM

>Why don't you create a new branch

I can work on a local copy for now, anyway I plan to retry the branch soon.

>Anybody in favor of a switch to Mercurial?

+1

Developer
Sep 23, 2011 at 2:47 PM

wow the branch is alive!

https://sharpmap.svn.codeplex.com/svn/Branches/0.9-GeoJSON

Developer
Sep 27, 2011 at 12:02 PM

I've refactored WmsServer class and added an experimental (actually, very trivial, but it works) geojson support. Enjoy :)

Developer
Dec 16, 2011 at 2:07 PM

Hi,

I have moved parts of the GeoJSON to the trunk to make GetFeatureInfo  with GeoJson possible. In my opinion, the GeoJSON code from D_Guidi works well, but isn't a renderer, so it should not be there. Instead I thought it would be a converter, so I put it in de converter part of SharpMap.

I restructured the GetFeatureInfo part of the WMS server a bit: there are now two additional functions which do the conversion from the FeatureDataSet to text/plain and text/json.

 

By the way, you can abuse the GetFeatureInfo to get all the features in the map as GeoJSON by doing the following: Set a pixelSensitivity for the WMS for instance at 10px. Build a proper GetFeatureInfo request and set the BBOX part to the whole map. Set the map size to 20x20 pixels and the I and J where has been 'clicked' to 10,10. Set the FEATURE_COUNT to a number larger than the number of features in your map and the WMS will give you all the features as GeoJSON :-)

 

Can everybody agree that the GeoJSON code should be in the Converters part of SharpMap?

Developer
Dec 16, 2011 at 2:23 PM
PeaceNlove wrote:

Can everybody agree that the GeoJSON code should be in the Converters part of SharpMap?

Absolutely.

My implementation is a Wms.GetMap that returns geojson instrad of images, that is a wrong thing to do (or, at least, none of the wms servers that I know supports this feature); to me, also GetFeatureInfo isn't a good idea but maybe is ok as a workaround.

A better way is to have a WFS implementation with support for geojson, something that GeoServer supports: here you can also specify a subset of the attributes to retrieve, that can be useful to reduce weight of the http calls.

Developer
Dec 16, 2011 at 2:59 PM

A good WFS with GeoJSON support is also something I want so I agree with you, but I still haven't found the time to create one :-( (I will need it in the end so my current strategy is to get an intern and to let him or her do the WFS coding, alongside with other interesting stuff).

Developer
Dec 16, 2011 at 3:01 PM
PeaceNlove wrote:

A good WFS with GeoJSON support is also something I want so I agree with you, but I still haven't found the time to create one :-( (I will need it in the end so my current strategy is to get an intern and to let him or her do the WFS coding, alongside with other interesting stuff).

Happy to heat that :)

PS: I see that the trunk doesn'0t compile under FW 3.5, maybe it's time to delete VS2008 solution and projects...

Coordinator
Dec 16, 2011 at 3:03 PM

Yes, this was one of the points noted at the amstardam meeting that we should switch to FW 4.0

Developer
Dec 16, 2011 at 3:15 PM

My bad, I only updated the 2010 projects and solutions.

And I therefore agree that we should stop supporting VS2008

Developer
Dec 16, 2011 at 3:30 PM
PeaceNlove wrote:

My bad, I only updated the 2010 projects and solutions.

And I therefore agree that we should stop supporting VS2008

I've tried to fix and it's easy to do for sharpmap "core", but there are some problems with WinForms.

To me it's not a problem to stop VS2008 support, so I haven't committed any changes