gpt4 book ai didi

sql-server-2008 - GML 到 SQL 地理 - 24200 : The specified input does not represent a valid geography instance

转载 作者:行者123 更新时间:2023-12-02 02:14:31 25 4
gpt4 key购买 nike

我目前正在将 Google map 集成到我们的一个应用程序中。其中一项要求是将用户定义的区域存储到数据库中。为此,我一直在使用 SQL Server 2008 中的 Geography 类型。虽然我在大多数情况下都能正常工作,但我遇到了一个阻塞问题。

下面我有一些示例代码。我用 GML XML 字符串填充 Geography 对象,有些实例有效,有些则无效,我看不出它们无效的逻辑原因。

DECLARE @geoWork GEOGRAPHY
DECLARE @geoNotWork GEOGRAPHY
DECLARE @Work NVARCHAR(MAX)
DECLARE @DoesntWork NVARCHAR(MAX)

SET @Work = '<Polygon xmlns="http://www.opengis.net/gml">' +
'<exterior>' +
'<LinearRing>' +
'<posList>' +
'61.52269494598361 -6.50390625 50.84757295365389 -36.5625 32.69486597787505 -17.40234375 46.31658418182218 23.90625 61.52269494598361 -6.50390625' +
'</posList>' +
'</LinearRing>' +
'</exterior>' +
'</Polygon>'
SET @DoesntWork = '<Polygon xmlns="http://www.opengis.net/gml">' +
'<exterior>' +
'<LinearRing>' +
'<posList>' +
'51.8591074413996 -0.8425140380859375 51.790355567911845 -0.7051849365234375 51.75381501386028 -0.8191680908203125 51.80564283054998 -0.9180450439453125 51.8591074413996 -0.8425140380859375' +
'</posList>' +
'</LinearRing>' +
'</exterior>' +
'</Polygon>'

SET @geoWork = GEOGRAPHY::GeomFromGml(@Work, 4326)
SET @geoNotWork = GEOGRAPHY::GeomFromGml(@DoesntWork, 4326)

SELECT @geoWork.AsGml()
SELECT @geoNotWork.AsGml()

有效的多边形定义了一个巨大的区域(跨越几个国家的大小),而没有定义一个大城镇大小的多边形。失败的只是这些“较小”的领域。令人恼火的是,这个较小的还不够小,无法满足我的需要。谁能告诉我为什么会这样?

最佳答案

在您失败的示例中,您的数据有错误的方向

为了能够跟踪多边形的内部和外部,SQL geography 类型要求多边形具有正确的环方向More about this , 从中:

In an ellipsoidal system, a polygon has no meaning, or is ambiguous, without an orientation. For example, does a ring around the equator describe the northern or southern hemisphere? If we use the geography data type to store the spatial instance, we must specify the orientation of the ring and accurately describe the location of the instance. The interior of the polygon in an ellipsoidal system is defined by the left-hand rule.

如何解决:

"Fixing" Polygon Ring Orientation in SQL Server 2008 using T-SQL

关于sql-server-2008 - GML 到 SQL 地理 - 24200 : The specified input does not represent a valid geography instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11210523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com