我正在使用
X_Coord =CASE WHEN shape.STDimension() = 2 THEN shape.STCentroid().STX ELSE shape.STEnvelope().STCentroid().STX END,
Y_Coord =CASE WHEN shape.STDimension() = 2 THEN shape.STCentroid().STY ELSE shape.STEnvelope().STCentroid().STY END,
填充多边形几何表中的X和Y列。但是,我还想填充一个位置表,例如,多边形的质心出现在哪个地形图边界内。
此
LEFT OUTER JOIN atbi.dbo.TLU_TOPO_BOUNDS AS b
ON b.Shape.STContains(a.Shape) = 1
在点几何上工作正常,但由于两个原因在多边形上失败:它通常难以确定另一个多边形是“在...内”,并且由于理由#1,原因#2是致命错误。
那么我怎样才能获得相同的结果,使用多边形质心来确定插入的多边形质心位于另一个多边形几何表中的哪个对应多边形?
我在这里做的完整代码:
ALTER TRIGGER [dbo].[GRSM_WETLAND_POLY_GIS_Location_ID]
ON [dbo].[GRSM_WETLANDS_POLY]
INSTEAD OF INSERT
AS
BEGIN
SET NOCOUNT ON;
INSERT dbo.GRSM_WETLANDs_POLY(
OBJECTID, MapMethod, HError, MapSource, SourceDate,
EditDate, Notes, Meta_MID, X_Coord, Y_Coord, Coord_Units,
Coord_System, UTM_Zone, Accuracy_Notes, Unit_Code, Loc_Name,
Loc_Notes, Datum, Watershed, StreamName, NHDReachCode, Trail,
Road, Elevation, LAT, LON, Year_, County, ST, IsExtant, IsSenstive,
LocationDescription, LocationDirections, PlaceName, FCSubtype,
Landform, Area_Acres, Area_Hectares, DataFile, DataDictionary,
Max_PDOP, Max_HDOP, Corr_Type, Rcvr_Type, SHAPE, QuadName
)
SELECT
a.OBJECTID, a.MapMethod, a.HError, a.MapSource, a.SourceDate,
a.EditDate, a.Notes, a.Meta_MID, a.X_Coord, a.Y_Coord, a.Coord_Units,
a.Coord_System, a.UTM_Zone, a.Accuracy_Notes, a.Unit_Code, a.Loc_Name,
a.Loc_Notes, a.Datum, a.Watershed, a.StreamName, a.NHDReachCode, a.Trail,
a.Road, a.Elevation, a.LAT, a.LON, a.Year_, a.County, a.ST, a.IsExtant, a.IsSenstive,
a.LocationDescription, a.LocationDirections, a.PlaceName, a.FCSubtype,
a.Landform, a.Area_Acres, a.Area_Hectares, a.DataFile, a.DataDictionary,
a.Max_PDOP, a.Max_HDOP, a.Corr_Type, a.Rcvr_Type, a.SHAPE, a.QuadName
From
(
SELECT
OBJECTID, MapMethod, HError, MapSource, SourceDate,
EditDate, Notes, Meta_MID,
X_Coord =CASE WHEN shape.STDimension() = 2 THEN shape.STCentroid().STX ELSE shape.STEnvelope().STCentroid().STX END,
Y_Coord =CASE WHEN shape.STDimension() = 2 THEN shape.STCentroid().STY ELSE shape.STEnvelope().STCentroid().STY END,
Coord_Units,
Coord_System, UTM_Zone, Accuracy_Notes, Unit_Code, Loc_Name,
Loc_Notes, Datum, Watershed, StreamName, NHDReachCode, Trail,
Road, Elevation, LAT, LON, Year_, County, ST, IsExtant, IsSenstive,
LocationDescription, LocationDirections, PlaceName, FCSubtype,
Landform, Area_Acres, Area_Hectares, DataFile, DataDictionary,
Max_PDOP, Max_HDOP, Corr_Type, Rcvr_Type, SHAPE,QuadName
FROM inserted
) AS a
--Not working:
---spatial query, what topo quad is this point in?
--LEFT OUTER JOIN atbi.dbo.TLU_TOPO_BOUNDS AS b
--ON b.Shape.STContains(a.Shape) = 1 ;
end
GO
如果你不得不询问触发器的其余部分,那么它就位于ESRI SDE堆栈的顶部,因此当我必须处理强制性objectid时,简单的触发器应该变得复杂,但其他一切都在工作,只需要找出质心STwithin。谢谢!