Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matthew Jackson 17 posts 36 karma points
    Apr 07, 2015 @ 23:59
    Matthew Jackson
    0

    Spatial Datatypes, Petapoco and umbraco.

    Hey guys,

    This may be going outside of the scope for many users however it might be a challange for someone to work out if this is at all possible. So I thought Id throw it up and see what I get back from the community.

    I have been sold on using petapoco as an ORM for Umbraco, MVC solution as it seems fast, simple and easy to use. However I've come up a bit of a caveat. Cant quite get Spatial data types mapping correctly.

    When I take a look at the petapoco.cs file withinn umbraco 7.2.2 source I see that it appears to have limited support for types DBgeometry, DBGeography with use for SQLServer.

    So why cannot I create a table including DBgeometry CLR and why does it not map on table creation.

    seems like the competetion has this half working http://john.katsiotis.com/blog/petapoco-and-spatial-data-types https://github.com/toptensoftware/PetaPoco/issues/181

    It looks like it has something to do with umbracos implementation of petapoco. I beleive I will have to modfiy the umbraco souce to add a mapper but need some guidance on this....Cheers guys

    I dont want to have to change to entityframework at this stage. Plus with all the mapping these days thought we should be able to utilize spatial datatypes for storage of polygons etc for GEOJSON output. Seems logical..?

    StackTrace is as follows

    { Line 44: //Create DB table - and set overwrite to false Line 45: db.CreateTable

    Stack Trace:
    
    
    [InvalidOperationException: Sequence contains no matching element]
       System.Linq.Enumerable.First(IEnumerable`1 source, Func`2 predicate) +415
       Umbraco.Core.Persistence.SqlSyntax.SqlSyntaxProviderBase`1.FormatType(ColumnDefinition column) +1228
       Umbraco.Core.Persistence.SqlSyntax.SqlSyntaxProviderBase`1.Format(ColumnDefinition column) +155
       Umbraco.Core.Persistence.SqlSyntax.SqlSyntaxProviderBase`1.Format(IEnumerable`1 columns) +144
       Umbraco.Core.Persistence.SqlSyntax.SqlSyntaxProviderBase`1.Format(TableDefinition table) +131
       Umbraco.Core.Persistence.PetaPocoExtensions.CreateTable(Database db, Boolean overwrite, Type modelType) +161
       Umbraco.Core.Persistence.PetaPocoExtensions.CreateTable(Database db, Boolean overwrite) +121
       something.something.Events.RegisterEvents.ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) in something.logic\Events\RegisterEvents.cs:45
       Umbraco.Core.ApplicationEventHandler.OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) +62
       Umbraco.Core.CoreBootManager.<Complete>b__5(IApplicationEventHandler x) +79
       Umbraco.Core.EnumerableExtensions.ForEach(IEnumerable`1 items, Action`1 action) +204
       Umbraco.Core.CoreBootManager.Complete(Action`1 afterComplete) +185
       Umbraco.Web.WebBootManager.Complete(Action`1 afterComplete) +86
       Umbraco.Core.UmbracoApplicationBase.StartApplication(Object sender, EventArgs e) +241
       Umbraco.Core.UmbracoApplicationBase.Application_Start(Object sender, EventArgs e) +40
    
  • Matthew Jackson 17 posts 36 karma points
    Apr 08, 2015 @ 00:01
    Matthew Jackson
    0

    Just to update I have checked the umbraco source and petapoco.cs contains the updates as mentioned by John in the aforementioned post. But from the look of this umbraco itself may be the issue?

  • Matthew Jackson 17 posts 36 karma points
    Apr 08, 2015 @ 00:05
  • Peter Kongyik 28 posts 170 karma points
    Apr 08, 2015 @ 01:00
    Peter Kongyik
    0

    Hi Matthew,

    I don't kow whether mapping to spatial datatypes is possible or not with Petapoco, but as a workaround how about you map your types to doubles? Then you can create a System.Spatial.GeographyPoint class from the latitude and longitude doube coordinates.

    I would not consider bringing Entity Framework to the game at all, since Petapoco is much more lightweight and faster, not to mention Umbraco is built around Petapoco mini ORM.

    Cheers,
    Peter 

  • Matthew Jackson 17 posts 36 karma points
    Apr 08, 2015 @ 04:42
    Matthew Jackson
    0

    I could However as I intend on storing Polygons; which *can contain multiple if no many Points, I thought this would get rather messy from a database perspective. I just dont understand why Petapoco with Umbraco doesnt have support for this. Hopefully someone can tell me more on why. Its just makes for a much more cleaner solution.

  • Matthew Jackson 17 posts 36 karma points
    Apr 08, 2015 @ 11:23
    Matthew Jackson
    0

    OK.. looks like it fails on table creation within registerevents.cs, It works on create :) but then fails again on Read with the following error...Exception Details: returns null

    Any ideas guys.

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Apr 08, 2015 @ 14:38
    Ismail Mayat
    0

    Matthew,

    The spatial data you could store in the examine / lucene index and query on it using lucene spatial contrib package, if you dig around on our.umbraco it has been done a good article on lucene and spatial here https://www.leapinggorilla.com/Blog/Read/1010/spatial-search-in-lucenenet---worked-example.  The only thing to be aware of is the spatial data was properties on umbraco nodes, I am assuming you have another data source of spatial data that you are trying to push into sql server?

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft