This project is read-only.

Store geometries in SqlServer with SqlGeometry type

Jun 15, 2011 at 7:39 PM

Hello !

Live Geometry seems very interesting but before starting a project and using it I would like some advices.

I would like to retrieve geometries (polygons) from a custom database that stores geometries with the "Geometry" type of sqlserver. The final objective is to display them on a canvas, eventually modify them (using Live geometry tools ?) and save changes on the database. Does "Live geometry" seems a good tool for doing that ? Any idea of the easy way to do that ? It seems that live geometry has it's own "Point" class and it's not using existing wpf class... Does writing an adapter to convert sqlserver geometry to livegeometry "Figures" is possible ?

 

Thank for any response,

Jun 15, 2011 at 8:10 PM

Hi,

Live Geometry is a good tool for your purpose. Writing an adapter to convert SQL Server geometry to Live Geometry figures is very easy. Just use the Factory.CreatePolygon(...), Factory.CreatePoint(...) and similar methods.

Thanks,

Kirill

Jul 22, 2011 at 10:15 AM

Hello !

Thanks for you help. I have a new question :

I want to use the top left corner of my canvas as the orign point of the live geometry grid and keep the default WPF canvas coordinates system (X increasing on the right and Y increasing on the bottom). Is it possible to do that simply ? How ?

Thank you

Jul 25, 2011 at 8:24 AM

Take a look at the CoordinateSystem.cs class (http://livegeometry.codeplex.com/SourceControl/changeset/view/68218#963427). There's Origin and there's UnitLength. By setting Origin to (0, 0) and UnitLength to 1.0 you can basically achieve what you want. You also need to flip the coordinates upside down (override the ToLogical() and ToPhysical() methods to not negate the Y coordinate). I can't tell if you'll need to derive from CoordinateSystem or you could get away with the existing one. If you end up needing minor modifications to the CoordinateSystem to get what you want, send us a patch and we'll look into making the change for you.

Thanks,

@KirillOsenkov