JavaScript

通用配置集

https://developers.arcgis.com/downloads/#javascript

Front字体—MIME类型

  1. .pbf application/octet-stream
  2. .ttf application/octet-stream
  3. .wasm application/wasm
  4. .woff application/font-woff
  5. .woff2 application/font-woff2
  6. .wsv application/octet-stream
  7. https://static.arcgis.com/fonts/arial-unicode-ms-regular/65280-65535.pbf
  8. esriConfig.fontsUrl = "http://127.0.0.1/arcgis_js_api/arial-unicode-ms-regular";

4.x

esri

Basemap

AMD:require([“esri/Basemap”], (Basemap) => { / code goes here / });
ESM:import Basemap from “@arcgis/core/Basemap”;
数据源类型:tiled services

服务来源:PortalItem 的 basemap ID(内置)、地图服务

  1. var basemap = new Basemap({
  2. portalItem: {
  3. id: "8dda0e7b5e2d4fafa80132d59122268c" // WGS84 Streets Vector webmap
  4. },//引入Portal发布的服务
  5. baseLayers: [
  6. new WebTileLayer({
  7. url: "url to your dynamic MapServer",
  8. title: "Basemap"
  9. });
  10. ],
  11. referenceLayers: [
  12. new WebTileLayer(...);
  13. ],
  14. });

esri/tasks/GeometryService esri/tasks/support/AreasAndLengthsParameters 计算图形

Query查询

初始化

  1. var spatialRef = new SpatialReference({
  2. wkid: view.spatialReference,
  3. });

3.x

ArcObject 10.x

获取图形节点

  1. geometry.GeometryType == esriGeometryType.esriGeometryPolyline;
  2. geometry.GeometryType == esriGeometryType.esriGeometryPolygon;
  3. IGeometryCollection geoCol = (IGeometryCollection)geometry;
  4. int geomsize = geoCol.GeometryCount;
  5. for (int lgeom = 0; lgeom < geomsize; lgeom++)
  6. {
  7. //从GeometryCollection得到SegmentCollection
  8. ISegmentCollection segCol = (ISegmentCollection)geoCol.get_Geometry(lgeom);
  9. IPath path = (IPath)geoCol.get_Geometry(lgeom);
  10. endPointCol.Add(path.FromPoint); //得到首尾节点
  11. endPointCol.Add(path.ToPoint);
  12. int segsize = segCol.SegmentCount;
  13. for (int lseg = 0; lseg < segsize; lseg++)
  14. {
  15. ISegment segment = segCol.get_Segment(lseg); //从SegmentCollection得到Segment
  16. screenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
  17. screenDisplay.SetSymbol((ISymbol)vertexMarkerSymbol);
  18. screenDisplay.DrawPoint(segment.FromPoint); //重画Segment的端点
  19. screenDisplay.DrawPoint(segment.ToPoint);
  20. screenDisplay.FinishDrawing();
  21. }
  22. }

释放资源

Marshal.ReleaseComObject

去除Z值

IZAware pZAware = pGeometry as IZAware;
pZAware.ZAware = false;

GP工具

  1. Geoprocessor gp = new Geoprocessor();
  2. gp.OverwriteOutput = true;
  3. //筛选
  4. IFeatureClass ofc;
  5. IQueryFilter oqf;
  6. MakeFeatureLayer makeLayer = new MakeFeatureLayer();
  7. makeLayer.in_features = graphicClass;
  8. object outLayer = "out_layer";
  9. makeLayer.out_layer = outLayer;
  10. makeLayer.where_clause = "PID = '" + Pid + "'";
  11. IGeoProcessorResult pResult = (IGeoProcessorResult)gp.Execute(makeLayer, null);
  12. IGPUtilities gpUtils = new GPUtilitiesClass();
  13. gpUtils.DecodeFeatureLayer(pResult.GetOutput(0), out ofc, out oqf);
  14. //裁剪
  15. ESRI.ArcGIS.AnalysisTools.Clip pClip2018 = new ESRI.ArcGIS.AnalysisTools.Clip();
  16. pClip2018.in_features = dL2018Class as object;
  17. pClip2018.clip_features = outLayer;
  18. object outLayer2018 = Gdb + "\\DL_XJ" + DateTime.Now.ToString("yyyyMMddHHmmss");
  19. pClip2018.out_feature_class = outLayer2018;
  20. pResult= new GeoProcessorResultClass();
  21. pResult = (IGeoProcessorResult)gp.Execute(pClip2018, null);
  22. IFeatureClass outFeatureClass = gp.Open(pResult.ReturnValue) as IFeatureClass;
  23. //相交
  24. Intersect pIntersect = new Intersect();
  25. IGpValueTableObject gpValueTableObject = new GpValueTableObjectClass();
  26. gpValueTableObject.SetColumns(2);
  27. object inputfeature = dL2018Class;
  28. object obj = outLayer;
  29. gpValueTableObject.AddRow(ref obj);
  30. gpValueTableObject.AddRow(ref inputfeature);
  31. pIntersect.in_features = gpValueTableObject;
  32. object outLayer_Intersect = Gdb + "\\DL_XJ" + DateTime.Now.ToString("yyyyMMddHHmmss");
  33. pIntersect.out_feature_class = outLayer_Intersect;
  34. pIntersect.join_attributes = "All";
  35. pResult = new GeoProcessorResultClass();
  36. pResult = (IGeoProcessorResult)gp.Execute(pIntersect, null);
  37. IFeatureClass outFeatureClass = gp.Open(pResult.ReturnValue) as IFeatureClass;

负面积处理

  1. public static void RepairGeometry(ref IGeometry geometry)
  2. {
  3. switch (geometry.GeometryType)
  4. {
  5. case esriGeometryType.esriGeometryPolygon:
  6. if (GeometryService.DirectionIsIncorrect(geometry))
  7. {
  8. IPolygon polygon = geometry as IPolygon;
  9. if (polygon != null)
  10. {
  11. IGeometryCollection pGeoCollection = new PolygonClass();
  12. pGeoCollection = polygon as IGeometryCollection;
  13. if (pGeoCollection.GeometryCount > 1)
  14. {
  15. IGeometryCollection pGeoCollection2 = new PolygonClass();
  16. object o = Type.Missing;
  17. // 遍历Ring集合
  18. for (int i = 0; i < pGeoCollection.GeometryCount; i++)
  19. {
  20. // 向Polygon对象中添加Ring子对象
  21. pGeoCollection2.AddGeometry(pGeoCollection.get_Geometry(i) as IGeometry, ref o, ref o);
  22. }
  23. // QI至ITopologicalOperator ==> 确保添加子对象后的Polygon对象是有效的
  24. ITopologicalOperator pTopological = pGeoCollection2 as ITopologicalOperator;
  25. // 执行Simplify操作 ,防止出现子对象覆盖现象
  26. pTopological.Simplify();
  27. geometry = pGeoCollection2 as IPolygon;
  28. }
  29. else
  30. {
  31. polygon.ReverseOrientation();
  32. }
  33. }
  34. }
  35. break;
  36. case esriGeometryType.esriGeometryPolyline:
  37. IPolyline pl = geometry as IPolyline;
  38. pl.ReverseOrientation();
  39. break;
  40. default:
  41. break;
  42. }
  43. }

图形绘制方向有错

  1. public static bool DirectionIsIncorrect(IGeometry geometry)
  2. {
  3. if (geometry == null)
  4. {
  5. return false;
  6. }
  7. if (geometry.IsEmpty)
  8. {
  9. return false;
  10. }
  11. if (geometry is IPolygon)
  12. {
  13. IArea area = geometry as IArea;
  14. return (area.Area < 0.0);
  15. }
  16. return ((geometry is IPolyline) && (((IPolyline)geometry).Length < 0.0));
  17. }