将数据加载到地理数据类型时遇到了麻烦:
DECLARE @g geography;
DECLARE @x xml;
SET @x = '<gml:MultiSurface gml:id="HVO.20584" srsName="urn:ogc:def:crs:EPSG::5514" srsDimension="2" xmlns:gml="http://www.opengis.net/gml/3.2">
<gml:surfaceMember>
<gml:Polygon gml:id="HVO.20584.1">
<gml:exterior>
<gml:LinearRing>
<gml:posList>-747267.00 -1056204.00 -747226.00 -1056232.00 -747239.00 -1056253.00 -747251.00 -1056278.00 -747267.00 -1056315.00 -747291.00 -1056365.00 -747337.00 -1056470.00 -747311.00 -1056474.00 -747244.00 -1056475.00 -747155.00 -1056467.00 -747077.00 -1056501.00 -747112.00 -1057366.00 -747263.00 -1057857.00 -747263.20 -1057857.05 -747263.30 -1057856.60 -747272.50 -1057858.50 -747276.10 -1057850.21 -747285.47 -1057849.89 -747295.34 -1057849.55 -747308.73 -1057848.34 -747320.38 -1057847.28 -747346.97 -1057857.70 -747358.66 -1057860.00 -747374.12 -1057860.55 -747386.06 -1057860.19 -747407.98 -1057859.54 -747444.60 -1057874.26 -747447.75 -1057879.52 -747454.57 -1057890.92 -747674.02 -1057865.46 -747851.54 -1057841.44 -747855.78 -1057838.67 -747871.68 -1057851.47 -747902.20 -1057870.55 -747916.06 -1057881.32 -747934.07 -1057891.87 -747960.03 -1057915.53 -747985.14 -1057954.40 -748001.13 -1057977.02 -748021.22 -1058003.59 -748088.58 -1058092.68 -748104.73 -1058095.49 -748166.00 -1058032.60 -748193.50 -1058002.40 -748214.40 -1057982.20 -748216.40 -1057988.60 -748293.20 -1058053.20 -748297.14 -1058050.03 -748302.55 -1058045.67 -748306.53 -1058042.47 -748311.89 -1058038.15 -748316.50 -1058034.44 -748320.83 -1058030.95 -748330.04 -1058023.54 -748332.15 -1058021.83 -748337.10 -1058017.85 -748341.39 -1058014.39 -748353.30 -1058004.80 -748347.67 -1057996.70 -748338.28 -1057981.31 -748335.70 -1057977.29 -748332.12 -1057971.71 -748330.30 -1057968.92 -748325.55 -1057961.32 -748317.05 -1057947.55 -748310.89 -1057935.02 -748307.10 -1057924.52 -748302.70 -1057912.35 -748298.54 -1057900.12 -748295.48 -1057891.13 -748286.20 -1057862.27 -748278.37 -1057838.25 -748276.55 -1057834.04 -748267.49 -1057808.20 -748264.92 -1057798.33 -748262.21 -1057787.93 -748254.57 -1057761.59 -748251.89 -1057752.13 -748247.59 -1057736.93 -748240.11 -1057716.13 -748237.47 -1057685.67 -748234.93 -1057657.42 -748234.51 -1057652.51 -748234.98 -1057625.54 -748234.51 -1057622.46 -748231.40 -1057602.21 -748233.13 -1057596.29 -748234.13 -1057592.87 -748237.61 -1057582.60 -748238.48 -1057580.02 -748249.72 -1057571.70 -748250.10 -1057571.42 -748252.39 -1057569.73 -748256.83 -1057563.57 -748258.55 -1057540.99 -748250.24 -1057535.67 -748250.94 -1057526.41 -748243.01 -1057522.35 -748236.51 -1057522.75 -748234.73 -1057522.86 -748230.54 -1057518.95 -748211.65 -1057501.36 -748199.48 -1057493.59 -748189.98 -1057489.26 -748179.90 -1057484.66 -748168.54 -1057470.65 -748168.29 -1057470.34 -748165.98 -1057467.49 -748157.92 -1057458.13 -748147.31 -1057450.99 -748146.04 -1057423.54 -748145.40 -1057410.42 -748144.91 -1057400.47 -748144.08 -1057372.43 -748142.62 -1057348.91 -748142.48 -1057347.16 -748141.05 -1057329.37 -748142.26 -1057321.94 -748146.21 -1057304.13 -748148.14 -1057295.42 -748146.30 -1057289.44 -748144.73 -1057284.34 -748141.64 -1057275.31 -748144.63 -1057272.64 -748154.01 -1057247.80 -748151.29 -1057246.55 -748127.50 -1057235.56 -748110.70 -1057228.23 -748082.39 -1057214.75 -748057.48 -1057203.76 -748041.82 -1057196.01 -748029.14 -1057189.74 -748010.10 -1057178.36 -747979.25 -1057161.25 -747957.25 -1057147.63 -747943.14 -1057138.66 -747937.35 -1057131.26 -747926.97 -1057121.60 -747909.48 -1057109.13 -747904.01 -1057106.36 -747895.25 -1057106.99 -747873.33 -1057094.64 -747869.74 -1057093.00 -747851.77 -1057082.31 -747869.79 -1057044.54 -747836.92 -1057032.09 -747795.65 -1057016.73 -747793.70 -1057009.93 -747787.82 -1056992.87 -747781.28 -1056974.44 -747776.81 -1056960.35 -747768.14 -1056933.57 -747762.16 -1056911.71 -747757.80 -1056895.21 -747753.30 -1056877.50 -747749.17 -1056859.18 -747744.25 -1056838.69 -747741.79 -1056821.91 -747739.99 -1056803.90 -747737.12 -1056781.92 -747735.82 -1056761.48 -747735.01 -1056740.42 -747736.57 -1056718.66 -747738.55 -1056694.68 -747741.17 -1056669.07 -747744.02 -1056634.01 -747745.17 -1056623.46 -747748.09 -1056596.69 -747755.37 -1056564.46 -747759.01 -1056547.20 -747761.29 -1056536.38 -747761.56 -1056535.10 -747772.54 -1056491.85 -747774.05 -1056485.90 -747786.35 -1056435.41 -747786.99 -1056433.22 -747796.41 -1056400.93 -747799.01 -1056392.00 -747799.01 -1056392.00 -747799.00 -1056392.00 -747723.00 -1056390.00 -747615.00 -1056374.00 -747596.00 -1056372.00 -747564.00 -1056375.00 -747539.00 -1056382.00 -747513.00 -1056389.00 -747487.00 -1056344.00 -747472.00 -1056316.00 -747458.00 -1056290.00 -747455.00 -1056283.00 -747445.00 -1056265.00 -747433.00 -1056243.00 -747424.00 -1056225.00 -747420.00 -1056218.00 -747412.00 -1056205.00 -747399.00 -1056188.00 -747388.00 -1056173.00 -747383.00 -1056167.00 -747371.00 -1056154.00 -747370.00 -1056153.00 -747362.00 -1056145.00 -747356.00 -1056141.00 -747356.00 -1056140.00 -747334.00 -1056160.00 -747267.00 -1056204.00</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>';
SET @g = geography::GeomFromGml(@x, 4326);
我得到了这个例外:
执行用户定义时发生.NET Framework错误 例程或聚合&#34; geography&#34;:System.FormatException:24129:The 给定的XML实例无效,因为顶级标记是 GML:个MultiSurface。输入地理标记的顶级元素 语言(GML)必须包含Point,LineString,Polygon,MultiPoint, MultiGeometry,MultiCurve,MultiSurface,Arc,ArcString, CompositeCurve,PolygonPatch或FullGlobe(仅限地理数据类型) 对象
我需要在@x
变量中进行哪些更改才能使其正常工作?
由于
答案 0 :(得分:0)
注意,这里的答案是指处理上述坐标的问题,这些问题不是注释中提出的测地线,而是解析XML的原始问题,这在评论中得到了回答。 的
经过一番挖掘后,似乎捷克共和国的预测现在被称为http://spatialreference.org/ref/sr-org/czech-s-jtsk-gis-esri102067/。如果您查看该页面,您将看到坐标以米为单位,并且是负数,就像在上面的XML中一样。此WKT表示为您提供有关投影的基准,椭球体和其他特征的信息。
SQL Server当前不支持从一个坐标系投影到另一个坐标系,因此您有两个选项。
1)。按原样加载,但作为几何而不是地理数据类型,因此上面的最后一行将成为
SET @g = geometry::GeomFromGml(@x, 5514);
其中9819似乎是上述链接中的SRID代码(虽然它有点不清楚)。这实际上并不重要,因为您无法从一个空间参照系转换到另一个空间参考系,但您可以在几何上执行任何几何函数,例如STIntersects
,{ {1}},STContains
等
2)。将其转换为SQL Server外部的lat / lon(4326),然后作为 geography 数据类型导入,如果它是您真正想要的。有一个名为 gdaltransform 的工具可以做到这一点,例如,
STBuffer
您输入第一行,使用投影信息,点击返回,然后输入坐标,然后您就会得到答案。从这里可以看出它给出的是纬度/经度14.38,49.96,它位于Prague,所以绝对是捷克共和国。
这种方法不具备可扩展性,因此您可能希望查看类似Proj4j的内容,这是一个用于进行坐标转换的Java库。