1

我目前正在使用

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。谢谢!

4

0 回答 0