DbGeography的FromText在C#中引发错误 [英] DbGeography's FromText throwing error in c#

查看:99
本文介绍了DbGeography的FromText在C#中引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 System.Data.Entity.Spatial.DbGeography.FromText()方法将Google地图地理json数据转换为 DbGeography 数据类型以将其保存到SQL数据库.有时会引发错误

"24201:纬度值必须在-90到90度之间."

以下是我在美国绘制的多边形点及其在转换时的抛出错误:

<预> <代码> POLYGON((40.6806380252146 -106.8310546875,40.6639728763869 -93.7353515625,34.8318411498286 -93.27392578125,37.9788450404971 -97.84423828125,35.3890499669117 -98.96484375,38.3244204270065 -100.43701171875,35.3173663292379 -102.48046875,38.5481654230466 -103.60107421875,35.5143431343182 -104.9853515625,37.7880813841205 -105.93017578125,36.6155276313492-111.26953125,38.8397076135451 -107.7978515625,38.685509760012 -111.24755859375,40.111688665596 -108.74267578125,38.8568201347436 -105.79833984375,40.6806380252146 -106.8310546875)

即使抛出错误也有以下几点:

  POINT(39.2369068303763 -105.542221069336) 

解决方案

POINT(-105.542221069336 39.2369068303763)能给您带来什么期望?

如果是这样的话,这些条款似乎与您的期望相反.

I am using System.Data.Entity.Spatial.DbGeography.FromText() method to convert the Google map geographical json data to DbGeography data type to save it into SQL database. Sometimes its throwing the error

"24201: Latitude values must be between -90 and 90 degrees."

Following are the polygon points which I have drawn on United States and its throwing error while conversion:

POLYGON(( 40.6806380252146 -106.8310546875, 40.6639728763869 -93.7353515625, 34.8318411498286 -93.27392578125, 37.9788450404971 -97.84423828125, 35.3890499669117 -98.96484375, 38.3244204270065 -100.43701171875, 35.3173663292379 -102.48046875, 38.5481654230466 -103.60107421875, 35.5143431343182 -104.9853515625, 37.7880813841205 -105.93017578125, 36.6155276313492 -111.26953125, 38.8397076135451 -107.7978515625, 38.685509760012 -111.24755859375, 40.111688665596 -108.74267578125, 38.8568201347436 -105.79833984375, 40.6806380252146 -106.8310546875))

Even its throwing error with below points:

POINT(39.2369068303763 -105.542221069336)

解决方案

Does POINT(-105.542221069336 39.2369068303763) give you what you expect?

If so it seems likely the terms are reversed from what you are expecting.

这篇关于DbGeography的FromText在C#中引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆