2012-01-18 102 views
1

我很努力地理解如何使用空間數據。我已經使用shape2sql將形狀文件上傳到SQL Server。形狀文件中的座標顯然是幾何類型。如何檢查點是否與多邊形相交

在我的數據庫表我現在有一個多邊形

'POLYGON ((1327562.625 6625818.5, 1327532.125 6625818.5, 1327506.625 6625817, 1327477.5 6625813, 1327452.125 6625808, 1327428 6625798.5, 1327392.5 6625779.5, 1327359.625 6625762.5, 1327331.75 6625748.5, 1327295 6625730.5, 1327260.375 6625693, 1327214 6625694.5, 1327196.75 6625674.5, 1327157 6625672.5, 1327124 6625659.5, 1327096.125 6625649, 1327064.5 6625637.5, 1327034 6625625.5, 1326999.875 6625609, 1326970.75 6625587, 1326950.625 6625570.5, 1326923.875 6625569, 1326914 6625538.5, 1326910.5 6625499, 1326908.125 6625470, 1326907.125 6625443, 1326883.875 6625379, 1326838.75 6625350.5, 1326780.375 6625106, 1326766.75 6625049, 1326759.5 6625019, 1326748 6624971, 1326734.75 6624915, 1326723.625 6624874.5, 1326721.375 6624839, 1326719.125 6624807, 1326719.375 6624766.5, 1326719.625 6624738.5, 1326719.875 6624709.5, 1326722.75 6624679, 1326723 6624636, 1326723.25 6624603, 1326721 6624572.5, 1326713.625 6624539.5, 1326702.5 6624510, 1326687.5 6624474.5, 1326673.75 6624440, 1326660.125 6624408, 1326646.375 6624375, 1326631.375 6624346, 1326616.375 6624316.5, 1326601.25 6624293.5, 1326586.125 6624273, 1326559.75 6624238.5, 1326544.625 6624217, 1326520.875 6624180, 1326493.375 6624122.5, 1326473.25 6624092, 1326448.125 6624055, 1326424.25 6624023, 1326400.375 6623988.5, 1326380.25 6623953, 1326365.375 6623920, 1326352.875 6623885.5, 1326340.5 6623852.5, 1326325.5 6623809, 1326320.625 6623784, 1326320.875 6623757, 1326321.125 6623723, 1326322.625 6623693.5, 1326325.375 6623667, 1326330.75 6623635.5, 1326352.625 6623604, 1326366.75 6623582.5, 1326401.75 6623537, 1326439.75 6623520.5, 1326482 6623492, 1326515.125 6623471.5, 1326548.375 6623453, 1326573.875 6623439, 1326599.5 6623426.5, 1326632.625 6623413, 1326664.5 6623403, 1326695.125 6623393, 1326730.75 6623378, 1326772.875 6623362, 1326809.875 6623349.5, 1326842.875 6623347.5, 1326873.5 6623343.5, 1326899.125 6623317, 1326935 6623280.5, 1326959.375 6623255.5, 1326971 6623230, 1326977.625 6623197, 1326983 6623170.5, 1326993.25 6623146.5, 1326994.75 6623120, 1326995.125 6623084.5, 1326996.625 6623059, 1327001.875 6623032.5, 1327019.875 6623003.5, 1327044.375 6622970.5, 1327067.5 6622931.5, 1327088.125 6622906, 1327103.5 6622883.5, 1327125.375 6622846.5, 1327142.25 6622806.5, 1327151.375 6622778.5, 1327164.375 6622747, 1327178.625 6622720, 1327198 6622678.5, 1327205.875 6622653, 1327213.625 6622626.5, 1327230.625 6622583.5, 1327246.125 6622552, 1327261.625 6622518, 1327275.875 6622483.5, 1327288.75 6622457, 1327301.75 6622425.5, 1327312.125 6622402.5, 1327323.75 6622378.5, 1327336.75 6622353.5, 1327348.375 6622330.5, 1327367.625 6622295, 1327388.375 6622258.5, 1327414 6622223, 1327432 6622203, 1327448.75 6622180.5, 1327469.25 6622151, 1327492.5 6622118.5, 1327516.875 6622088, 1327545.125 6622056.5, 1327570.75 6622021.5, 1327596.5 6621989.5, 1327619.625 6621958, 1327644.125 6621921.5, 1327666 6621890, 1327693 6621846, 1327712.375 6621814, 1327731.625 6621780, 1327756.125 6621741, 1327778 6621705.5, 1327801.25 6621664, 1327816.75 6621637.5, 1327840 6621598, 1327860.5 6621569, 1327882.375 6621544, 1327908 6621523.5, 1327936.125 6621503.5, 1327968 6621486, 1327998.75 6621463.5, 1328031.875 6621441, 1328063.875 6621424.5, 1328098.375 6621407, 1328135.375 6621391, 1328167.25 6621376, 1328196.625 6621359.5, 1328222.125 6621343.5, 1328246.375 6621328, 1328270.625 6621318.5, 1328301.25 6621309.5, 1328340.75 6621305, 1328368.75 6621298.5, 1328407 6621289, 1328449 6621279, 1328474.375 6621275.5, 1328501.125 6621275.5, 1328527.875 6621276, 1328557.125 6621274.5, 1328594 6621273.5, 1328633.375 6621275.5, 1328671.5 6621275.5, 1328707.125 6621276, 1328741.375 6621282.5, 1328787 6621293, 1328818.75 6621306, 1328846.5 6621324, 1328884.5 6621349.5, 1328909.75 6621360, 1328940.25 6621369, 1328971.875 6621379.5, 1329001.125 6621388.5, 1329032.75 6621399, 1329058.125 6621409, 1329083.5 6621418, 1329108.75 6621430, 1329132.875 6621441.5, 1329158.125 6621455.5, 1329182.25 6621468.5, 1329205 6621481.5, 1329246.75 6621503, 1329284.75 6621517.5, 1329317.75 6621528, 1329370 6621522, 1329403 6621514.5, 1329428.5 6621507, 1329478 6621516.5, 1329528.875 6621523, 1329574.5 6621535, 1329599.875 6621541.5, 1329630.375 6621549.5, 1329663.375 6621553.5, 1329698.875 6621560, 1329730.5 6621580.5, 1329759.625 6621599.5, 1329787.5 6621612.5, 1329878.625 6621500.5, 1330416 6621701, 1330484.375 6621583.5, 1331722.625 6622039.5, 1331783.125 6622415.5, 1331786.75 6622441, 1331835 6622613, 1331837.25 6622639.5, 1331806 6622727, 1331743.375 6622771, 1331705 6622797, 1331684.5 6622818.5, 1331664 6622844, 1331647.25 6622865.5, 1331630.5 6622889.5, 1331607.375 6622922, 1331591.875 6622953.5, 1331580.125 6622991.5, 1331330.25 6624007.5, 1331168.875 6624933, 1330912.625 6624902, 1330720.875 6624917.5, 1330851.25 6625309, 1330245 6625523.5, 1330053.25 6625048, 1328694.875 6625608, 1328025.5 6625648.5, 1327997.375 6625650, 1327940.625 6625662.5, 1327897 6625672, 1327834 6625686.5, 1327810 6625718, 1327757.875 6625738.5, 1327730.75 6625772, 1327697.625 6625786.5, 1327664.375 6625801.5, 1327624.875 6625811.5, 1327593.125 6625816.5, 1327562.625 6625818.5)) 

我再定義從谷歌地圖的一個點,我ATLEAST認爲是該地區:

geometry::STPointFromText('POINT(59.528355 13.321609)',4326); 

最後我嘗試檢查重點在於使用STIntersects,但總是返回false。

我可以看到多邊形和點之間的座標格式似乎不同。這是問題嗎?如果是,我該如何解決?

回答

1

看起來像你的多邊形哈斯一個座標系,你的觀點在另一個。 4326是經緯度座標的epsg代碼,你的多邊形可以是任何東西,但可能是一些utm區域。

找出你的多邊形數據的EPSG代碼,並使用協調你的數據庫的轉換功能轉換爲EPSG 4326 ...

+0

謝謝!多邊形採用RT90格式,當我將其轉換爲WGS84時,它可以工作。 – RobinHu 2012-01-19 17:09:24

相關問題