sqlgeography

Change projection in MSSQL for web mapping (Leaflet,Openlayer, OpenStreetMaps, GoogleAPI, …) to WSG48 or any other format

放肆的年华 提交于 2019-12-05 12:23:30
I have some WKT/WKB data in the MSSQL server like this and would like to show them on the map with the help of leaflet, Openlayer, OpenStreetMaps, or GoogleAPI. My data look likes this: POLYGON ((1736946.0983 5923253.9175, 1736895.6852 5923333.9451, 1736936.0082 5923356.6991, ......)) in this format EPSG:2193 as shown below and would like to convert them to WGS48 or EPSG:4326 I am trying to add them to leaflet, and seems that I need to convert this data to an appropriate format like this: [[42.353770, -71.103606], [42.355447, -71.104475], [42.362681, -71.089830], [42.361829, -71.079230]]

Spatial index slowing down query

非 Y 不嫁゛ 提交于 2019-12-05 09:36:14
Background I have a table that contains POLYGONS/MULTIPOLYGONS which represent customer territories: The table contains roughly 8,000 rows Approximately 90% of the polygons are circles The remainder of the polygons represent one or more states, provinces, or other geographic regions. The raw polygon data for these shapes was imported from US census data . The table has a spatial index and a clustered index on the primary key. No changes to the default SQL Server 2008 R2 settings were made. 16 cells per object, all levels medium. Here's a simplified query that will reproduce the issue that I'm

Mapping SqlGeography with Dapper

一个人想着一个人 提交于 2019-12-05 02:49:21
I have entity "Point", that contains Id, Text and geography coordinates. CREATE TABLE [Point] ( [Id] INT IDENTITY CONSTRAINT [PK_Point_Id] PRIMARY KEY, [Coords] GEOGRAPHY NOT NULL, [Text] NVARCHAR(32) NOT NULL, [CreationDate] DATETIME NOT NULL, [IsDeleted] BIT NOT NULL DEFAULT(0) ) CREATE PROCEDURE [InsertPoint] @text NVARCHAR(MAX), @coords GEOGRAPHY AS BEGIN INSERT INTO [Point](Text, Coords, CreationDate) VALUES(@text, @coords, GETUTCDATE()) SELECT * FROM [Point] WHERE [Id] = SCOPE_IDENTITY() END This is ts sql code of table and stored procedure of inserting. I have class for using dapper :

No mapping exists from object type System.Data.Spatial.DbGeography to a known managed provider native type

馋奶兔 提交于 2019-12-04 18:48:07
I am building an app using the DotNetNuke 7 platform and am trying to write Geography data to the database. Here is some background on the project. I am building in VS 2012 and just upgraded to Server 2012 from 2008 R2. DotNetNuke 7 implements PetaPoco for the data layer and WebAPI. I hope what I provided is enough to information to understand the problem. My code fails on the line "rep.Insert(location);" using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Net; using System.Web; using System.Net.Http; using System.Web.Http; using System.Data

EntityType 'DbGeography' has no key defined

北慕城南 提交于 2019-12-04 15:22:48
问题 Long time listener, first time caller (finally made an account here!)... I am using Visual Studio 2013 with .NET 4.5.1 and Entity Framework 6 (final releases, not RC or beta). When trying to add a DbGeography property to my entity, I get this error upon execution: One or more validation errors were detected during model generation: Geocoder.DbGeography: : EntityType 'DbGeography' has no key defined. Define the key for this EntityType. DbGeographies: EntityType: EntitySet 'DbGeographies' is

SQL Server - From longitude and latitude to geometry data type [duplicate]

妖精的绣舞 提交于 2019-12-04 06:25:13
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: SQL Server 2008 Spatial: find a point in polygon I am working on an application that uses an SQL Server 2008 database. In this database I have a table named Session that has two fields Longitude and latitude, which indicate the location of a user. On another table called Zone, I have an area attribute which is of type geometry. How can I check if the user's longitude and latitude coordinates belong to a certain

Error getting value from 'WellKnownValue' on 'System.Data.Entity.Spatial.DbGeography

送分小仙女□ 提交于 2019-12-03 22:21:24
问题 I am using the DbGeography-Type within a SinglePageApplication (with breeze and angular). Now when using the Data with the DbGeography-Type (readOnly) there is no problem. As soon as I save an entity which has a property of DbGeography-Type I get the following error: Error getting value from 'WellKnownValue' on 'System.Data.Entity.Spatial.DbGeography' When the data is serialized to JSON (with newtonsoft JSON.NET or is it ODATA/WebAPI?), the DbGeography gets serialized correctly but the

How to correct Polygon Ring Orientation using C# Entity Framework 5 DbGeography Spatial Data

谁都会走 提交于 2019-12-03 14:16:32
I'm working with the new Entity-Framework 5 using the Spatial data type DbGeography as part of my model for storing in one instance, a POINT and in another instance a POLYGON. When setting the value of my POLYGON all saves with no error however this is only the case if I draw the Polygon on the map in a clockwise order. If I draw the POLGON in an anti-clockwise direction I get an error the the sql level indicating that the data is an invalid geography type. Now after doing my own research into the problem, it appears to stem from the geography data type being quite strict in terms of a

Create a SqlGeography polygon-circle from a center and radius

白昼怎懂夜的黑 提交于 2019-12-03 06:28:36
I would like to save a circle in a sql-server 2008 geography field, using c#. In c# I have a latitude, a longitude and a radius but I just can't find a way to calculate the polygon that would represent the circle and create a SqlGeography from it. I have tried to following function to create the polygon: private List<Coordinate> getCirclePoints(Coordinate center, int radius, int speed) //speed 1: draws 360 sides, 2 draws 180 etc... { var centerLat = (center.Latitude * Math.PI) / 180.0; //rad var centerLng = (center.Longitude * Math.PI) / 180.0; //rad var dist = (float)radius / 6371.0; //d =

SQL Server - From longitude and latitude to geometry data type [duplicate]

人走茶凉 提交于 2019-12-02 12:06:48
Possible Duplicate: SQL Server 2008 Spatial: find a point in polygon I am working on an application that uses an SQL Server 2008 database. In this database I have a table named Session that has two fields Longitude and latitude, which indicate the location of a user. On another table called Zone, I have an area attribute which is of type geometry. How can I check if the user's longitude and latitude coordinates belong to a certain geometry? Thank you David Manheim You have a geometry, which stores a shape in Euclidean geometry, and you want to associate a point on the globe, represented by a