1、导入SHP/CAD文件

  WEB具有直接美观展现功能,功能实现到可视化最好不要超过3S,那么就要限制导入文件的大小和优化算法了。

1.1、SHP导入实现思路

  SHP格式开源,Git上随便可以找到读取SHP的源码,读取后一般返回GeoJson或JSON格式的要素,然后解析GeoJson实现可视化,ArcGIS体系或OpenLayers体系。

 1 var jsonf = GeoJsonConverter();//GeoJson转Esri
2 shp(filename).then(function (data) {
3 var json = jsonf.toEsri(data);//ESRI要素
4 window.map.graphics.clear();
5 var featsarray = [];
6 for (var j = 0; j < json.features.length; j++) {
7 var ss = Graphic(json.features[j]);
8 ss.setSymbol(fillSymbol);
9 ss.geometry.setSpatialReference(window.map.spatialReference);
10 window.map.graphics.add(ss);
11 featsarray.push(ss);
12 }
13 var ptcen = featsarray[0].geometry.getExtent().getCenter();
14 window.map.setScale(4000);
15 window.map.centerAt(ptcen);
16 });

ArcGIS实现加载SHP文件

1.2、CAD导入实现思路

  CAD格式封闭,只好通过后台服务(AO/AE开发)或GP服务(要素转JSON,貌似ArcGIS10.3及以上才有),原理也是读取CAD文件后将其转为JSON格式,WEB前端解析JSON可视化显示。

(1)读取CAD:AO/AE开发读取,比较简单;读取后转为JSON可借助类JSONConverterGeometryClass,熟悉JSON结构也可以直接写代码。

/// <summary>
/// 提取feature的geometry,并将其转换为json对象
/// </summary>
/// <param name="pFeature">要素对象</param>
/// <returns></returns>
public static string feature2JsonGeometry(ESRI.ArcGIS.Geodatabase.IFeature pFeature)
{
ESRI.ArcGIS.Geometry.IGeometry pGeo = pFeature.Shape;
//return GeometryToJsonString(pGeo);
int wkid = pGeo.SpatialReference.FactoryCode;
ESRI.ArcGIS.Geometry.IPoint pPoint = null;
ESRI.ArcGIS.Geometry.IPointCollection pPoints = null;
double x, y;
StringBuilder sb = new StringBuilder("{"); switch (pGeo.GeometryType)
{
#region Point2Json
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
pPoint = pGeo as ESRI.ArcGIS.Geometry.IPoint;
pPoint.QueryCoords(out x, out y);
string json = @"""x"":" + x + @",""y"":" + y + @",""spatialReference"":" + @"{""wkid"":" + wkid + "}";
sb.Append(json);
break;
#endregion #region Polyline2Json
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
pPoints = pGeo as ESRI.ArcGIS.Geometry.IPointCollection;
sb.Append(@"""paths"":[[");
for (int i = ; i < pPoints.PointCount; i++)
{
pPoint = pPoints.get_Point(i);
pPoint.QueryCoords(out x, out y);
sb.Append("[" + x + "," + y + "],");
}
sb.Remove(sb.Length - , );
sb.Append("]]" + @",""spatialReference"":" + @"{""wkid"":" + wkid + "}");
break; #endregion #region Polygon2Json
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
pPoints = pGeo as ESRI.ArcGIS.Geometry.IPointCollection;
sb.Append(@"""rings"":[[");
for (int i = ; i < pPoints.PointCount; i++)
{
pPoint = pPoints.get_Point(i);
pPoint.QueryCoords(out x, out y);
sb.Append("[" + x + "," + y + "],");
}
sb.Remove(sb.Length - , );
sb.Append("]]" + @",""spatialReference"":" + @"{""wkid"":" + wkid + "}"); break;
#endregion
}
sb.Append("}");
return sb.ToString();
}

提取feature的geometry,并将其转换为json对象

(2)GP服务(要素转JSON),在高版本中工具箱——转换(Conversion)——JSON,执行后发布为GP服务,前端调用GPServer实现读取转为JSON。

$.ajax({
type: "post",
url: window.top.RootPath + "/fastGIS/pro/FastService.asmx/GetCADGraphicContent",
contentType: "application/json; charset=utf-8",
data: "{fileName:'" + filename + "'}",
success: function (result) {
console.log(result);
var jsons = result.d.split("|");
if (jsons) {
for(var i=0;i<jsons.length;i++){
var geore = JsonUtils.fromJson(JSON.parse(jsons[i]));//ArcGIS JS API函数解析
geore.setSpatialReference(window.top.map.spatialReference);
switch (geore.type) {
case "polygon":
window.top.map.graphics.add(Graphic(geore, fillSymbol));
break;
case "polyline":
window.top.map.graphics.add(Graphic(geore, lineSymbol));
break;
default:
break;
}
window.top.map.centerAt(geore.getPoint(0, 0));
}
}
window.top.map.setScale(4000);
},
error: function (err) {
console.log(err);
}
});

后台服务AJAX实现可视化

2、导出SHP/CAD文件

  导出是导入的逆向过程,要求从WebGIS的地图上(各种可视化地图)按照需求(比如按区域、按绘制范围)导出对应的图形和属性数据,前后台联合进行。

2.1 导出SHP文件实现思路

  在地图前台操作,肯定是需要通过绘制范围、选择对象查询符合区域的数据,将该区域的相关对象前台或后台处理;有2种方式,一种直接后台转JSON再输出为SHP文件,另一种就是全部后台运作,通过ArcGIS后台开发保存为SHP文件。

  此处参考博客:【http://blog.csdn.net/gis0911178/article/details/52162477】详细说明SHP文件,开源读取并生成SHP文件。【引用已说明出处,尊重原作】

2.2 导出CAD文件实现思路

  前面已说明CAD的DWG格式文件封闭,但DXF格式开源,因此可以直接写DXF输出文件;另外一种思路则是直接通过AO/AE开发后台,“导出SHP—转为CAD”这种思路输出DWG文件。

Geoprocessor gp = new Geoprocessor();
ExportCAD exCAD = new ExportCAD();//工具箱中的转为CAD工具
exCAD.Output_File = @fileDir + ".dwg";
exCAD.Output_Type = "DWG_R2004";
exCAD.in_features = @fileDir + "\\" + fileName + ".shp";
exCAD.Ignore_FileNames = "False";
try
{
var res = gp.Execute(exCAD, null);
return "/TemporaryFile/createSHP/" + fileName + ".dwg";
}
catch (Exception ee)
{ }

Geoprocessor实现SHP转CAD

另外写DXF输出文件也提供源码。

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Globalization; using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto; namespace Fast.FastMan.BUS.GisPro.CommonGIS
{
public class ConvertDXFArgs : System.EventArgs
{
bool result = false;
Exception ex = null; public ConvertDXFArgs()
{
result = true;
} public ConvertDXFArgs(Exception ex)
{
this.ex = ex;
} public bool Result
{
get { return result; }
} public Exception Exception
{
get { return ex; }
}
} public class ConvertDXF
{
public delegate void OnCompleted(object sender, ConvertDXFArgs e);
public event OnCompleted completed; struct ColorDXF
{
public byte Red;
public byte Green;
public byte Blue;
public ColorDXF(byte r, byte g, byte b)
{
Red = r;
Green = g;
Blue = b;
}
} struct TagDXF
{
public const string HEADER = "HEADER";
public const string TABLES = "TABLES";
public const string ENTITIES = "ENTITIES";
public const string BLOCKS = "BLOCKS";
} string m_Filename = null;
IFeatureLayer m_FeatureLayer = null;
TextWriter m_tw = null; public ConvertDXF(string filename, IFeatureLayer featureLayer)
{
m_Filename = filename;
m_FeatureLayer = featureLayer;
} public void Convert()
{
if ((m_FeatureLayer == null) || (string.IsNullOrEmpty(m_Filename)))
{
completed(this, new ConvertDXFArgs(new Exception("FeatureLayer is null or Filename is null")));
} try
{
m_tw = new StreamWriter(m_Filename); IEnvelope envelope = m_FeatureLayer.AreaOfInterest;
IFeatureClass featureClass = m_FeatureLayer.FeatureClass; Header(envelope);
Tables();
Blocks();
Entities(); completed(this, new ConvertDXFArgs());
}
catch (Exception ex)
{
completed(this, new ConvertDXFArgs(ex));
}
finally
{
m_tw.Close();
m_tw.Dispose();
m_tw = null;
} } /// <summary>
/// return color nearest Autocad
/// </summary>
/// <param name="intR"></param>
/// <param name="intG"></param>
/// <param name="intB"></param>
/// <returns></returns>
static ColorDXF GetColorDXF(ColorDXF c)
{
IDictionary<byte, string> dct = new Dictionary<byte, string>();
#region Dictionary Color
//item: colore come valore RGB, key: colore equivalent in AutoCAD
dct.Add(, "0|0|0");
dct.Add(, "255|0|0");
dct.Add(, "255|255|0");
dct.Add(, "0|255|0");
dct.Add(, "0|255|255");
dct.Add(, "0|0|255");
dct.Add(, "255|0|255");
dct.Add(, "255|255|255");
dct.Add(, "65|65|65");
dct.Add(, "128|128|128");
dct.Add(, "255|0|0");
dct.Add(, "255|170|170");
dct.Add(, "189|0|0");
dct.Add(, "189|126|126");
dct.Add(, "129|0|0");
dct.Add(, "129|86|86");
dct.Add(, "104|0|0");
dct.Add(, "104|69|69");
dct.Add(, "79|0|0");
dct.Add(, "79|53|53");
dct.Add(, "255|63|0");
dct.Add(, "255|191|170");
dct.Add(, "189|46|0");
dct.Add(, "189|141|126");
dct.Add(, "129|31|0");
dct.Add(, "129|96|86");
dct.Add(, "104|25|0");
dct.Add(, "104|78|69");
dct.Add(, "79|19|0");
dct.Add(, "79|59|53");
dct.Add(, "255|127|0");
dct.Add(, "255|212|170");
dct.Add(, "189|94|0");
dct.Add(, "189|157|126");
dct.Add(, "129|64|0");
dct.Add(, "129|107|86");
dct.Add(, "104|52|0");
dct.Add(, "104|86|69");
dct.Add(, "79|39|0");
dct.Add(, "79|66|53");
dct.Add(, "255|191|0");
dct.Add(, "255|234|170");
dct.Add(, "189|141|0");
dct.Add(, "189|173|126");
dct.Add(, "129|96|0");
dct.Add(, "129|118|86");
dct.Add(, "104|78|0");
dct.Add(, "104|95|69");
dct.Add(, "79|59|0");
dct.Add(, "79|73|53");
dct.Add(, "255|255|0");
dct.Add(, "255|255|170");
dct.Add(, "189|189|0");
dct.Add(, "189|189|126");
dct.Add(, "129|129|0");
dct.Add(, "129|129|86");
dct.Add(, "104|104|0");
dct.Add(, "104|104|69");
dct.Add(, "79|79|0");
dct.Add(, "79|79|53");
dct.Add(, "191|255|0");
dct.Add(, "234|255|170");
dct.Add(, "141|189|0");
dct.Add(, "173|189|126");
dct.Add(, "96|129|0");
dct.Add(, "118|129|86");
dct.Add(, "78|104|0");
dct.Add(, "95|104|69");
dct.Add(, "59|79|0");
dct.Add(, "73|79|53");
dct.Add(, "127|255|0");
dct.Add(, "212|255|170");
dct.Add(, "94|189|0");
dct.Add(, "157|189|126");
dct.Add(, "64|129|0");
dct.Add(, "107|129|86");
dct.Add(, "52|104|0");
dct.Add(, "86|104|69");
dct.Add(, "39|79|0");
dct.Add(, "66|79|53");
dct.Add(, "63|255|0");
dct.Add(, "191|255|170");
dct.Add(, "46|189|0");
dct.Add(, "141|189|126");
dct.Add(, "31|129|0");
dct.Add(, "96|129|86");
dct.Add(, "25|104|0");
dct.Add(, "78|104|69");
dct.Add(, "19|79|0");
dct.Add(, "59|79|53");
dct.Add(, "0|255|0");
dct.Add(, "170|255|170");
dct.Add(, "0|189|0");
dct.Add(, "126|189|126");
dct.Add(, "0|129|0");
dct.Add(, "86|129|86");
dct.Add(, "0|104|0");
dct.Add(, "69|104|69");
dct.Add(, "0|79|0");
dct.Add(, "53|79|53");
dct.Add(, "0|255|63");
dct.Add(, "170|255|191");
dct.Add(, "0|189|46");
dct.Add(, "126|189|141");
dct.Add(, "0|129|31");
dct.Add(, "86|129|96");
dct.Add(, "0|104|25");
dct.Add(, "69|104|78");
dct.Add(, "0|79|19");
dct.Add(, "53|79|59");
dct.Add(, "0|255|127");
dct.Add(, "170|255|212");
dct.Add(, "0|189|94");
dct.Add(, "126|189|157");
dct.Add(, "0|129|64");
dct.Add(, "86|129|107");
dct.Add(, "0|104|52");
dct.Add(, "69|104|86");
dct.Add(, "0|79|39");
dct.Add(, "53|79|66");
dct.Add(, "0|255|191");
dct.Add(, "170|255|234");
dct.Add(, "0|189|141");
dct.Add(, "126|189|173");
dct.Add(, "0|129|96");
dct.Add(, "86|129|118");
dct.Add(, "0|104|78");
dct.Add(, "69|104|95");
dct.Add(, "0|79|59");
dct.Add(, "53|79|73");
dct.Add(, "0|255|255");
dct.Add(, "170|255|255");
dct.Add(, "0|189|189");
dct.Add(, "126|189|189");
dct.Add(, "0|129|129");
dct.Add(, "86|129|129");
dct.Add(, "0|104|104");
dct.Add(, "69|104|104");
dct.Add(, "0|79|79");
dct.Add(, "53|79|79");
dct.Add(, "0|191|255");
dct.Add(, "170|234|255");
dct.Add(, "0|141|189");
dct.Add(, "126|173|189");
dct.Add(, "0|96|129");
dct.Add(, "86|118|129");
dct.Add(, "0|78|104");
dct.Add(, "69|95|104");
dct.Add(, "0|59|79");
dct.Add(, "53|73|79");
dct.Add(, "0|127|255");
dct.Add(, "170|212|255");
dct.Add(, "0|94|189");
dct.Add(, "126|157|189");
dct.Add(, "0|64|129");
dct.Add(, "86|107|129");
dct.Add(, "0|52|104");
dct.Add(, "69|86|104");
dct.Add(, "0|39|79");
dct.Add(, "53|66|79");
dct.Add(, "0|63|255");
dct.Add(, "170|191|255");
dct.Add(, "0|46|189");
dct.Add(, "126|141|189");
dct.Add(, "0|31|129");
dct.Add(, "86|96|129");
dct.Add(, "0|25|104");
dct.Add(, "69|78|104");
dct.Add(, "0|19|79");
dct.Add(, "53|59|79");
dct.Add(, "0|0|255");
dct.Add(, "170|170|255");
dct.Add(, "0|0|189");
dct.Add(, "126|126|189");
dct.Add(, "0|0|129");
dct.Add(, "86|86|129");
dct.Add(, "0|0|104");
dct.Add(, "69|69|104");
dct.Add(, "0|0|79");
dct.Add(, "53|53|79");
dct.Add(, "63|0|255");
dct.Add(, "191|170|255");
dct.Add(, "46|0|189");
dct.Add(, "141|126|189");
dct.Add(, "31|0|129");
dct.Add(, "96|86|129");
dct.Add(, "25|0|104");
dct.Add(, "78|69|104");
dct.Add(, "19|0|79");
dct.Add(, "59|53|79");
dct.Add(, "127|0|255");
dct.Add(, "212|170|255");
dct.Add(, "94|0|189");
dct.Add(, "157|126|189");
dct.Add(, "64|0|129");
dct.Add(, "107|86|129");
dct.Add(, "52|0|104");
dct.Add(, "86|69|104");
dct.Add(, "39|0|79");
dct.Add(, "66|53|79");
dct.Add(, "191|0|255");
dct.Add(, "234|170|255");
dct.Add(, "141|0|189");
dct.Add(, "173|126|189");
dct.Add(, "96|0|129");
dct.Add(, "118|86|129");
dct.Add(, "78|0|104");
dct.Add(, "95|69|104");
dct.Add(, "59|0|79");
dct.Add(, "73|53|79");
dct.Add(, "255|0|255");
dct.Add(, "255|170|255");
dct.Add(, "189|0|189");
dct.Add(, "189|126|189");
dct.Add(, "129|0|129");
dct.Add(, "129|86|129");
dct.Add(, "104|0|104");
dct.Add(, "104|69|104");
dct.Add(, "79|0|79");
dct.Add(, "79|53|79");
dct.Add(, "255|0|191");
dct.Add(, "255|170|234");
dct.Add(, "189|0|141");
dct.Add(, "189|126|173");
dct.Add(, "129|0|96");
dct.Add(, "129|86|118");
dct.Add(, "104|0|78");
dct.Add(, "104|69|95");
dct.Add(, "79|0|59");
dct.Add(, "79|53|73");
dct.Add(, "255|0|127");
dct.Add(, "255|170|212");
dct.Add(, "189|0|94");
dct.Add(, "189|126|157");
dct.Add(, "129|0|64");
dct.Add(, "129|86|107");
dct.Add(, "104|0|52");
dct.Add(, "104|69|86");
dct.Add(, "79|0|39");
dct.Add(, "79|53|66");
dct.Add(, "255|0|63");
dct.Add(, "255|170|191");
dct.Add(, "189|0|46");
dct.Add(, "189|126|141");
dct.Add(, "129|0|31");
dct.Add(, "129|86|96");
dct.Add(, "104|0|25");
dct.Add(, "104|69|78");
dct.Add(, "79|0|19");
dct.Add(, "79|53|59");
dct.Add(, "51|51|51");
dct.Add(, "80|80|80");
dct.Add(, "105|105|105");
dct.Add(, "130|130|130");
dct.Add(, "190|190|190");
dct.Add(, "255|255|255"); #endregion Dictionary Color string[] sColorCAD; //tutti possibili colori della collection
byte bGCAD, bRCAD, bBCAD; //valori RGB di tutti colori
byte color = ; //color nearest of collection
double dblTemp = Double.MaxValue;
double dblDistance; foreach (byte idx in dct.Keys)
{
sColorCAD = dct[idx].Split('|');
bRCAD = byte.Parse(sColorCAD[]);
bGCAD = byte.Parse(sColorCAD[]);
bBCAD = byte.Parse(sColorCAD[]); dblDistance = System.Math.Sqrt((bRCAD - c.Red) ^ + (bGCAD - c.Green) ^ + (bBCAD - c.Blue) ^ ); if (dblDistance < dblTemp)
{
dblTemp = dblDistance;
color = idx;
if (dblTemp == )
break; }
} //color "0" (not defined) -> color "7" (default of AutoCAD)
if (color == )
color = ; string[] r = dct[color].Split('|');
return new ColorDXF(byte.Parse(r[]), byte.Parse(r[]), byte.Parse(r[]));
}
static IFormatProvider GetFormatProvider()
{
NumberFormatInfo nfi = new NumberFormatInfo();
nfi.CurrencyDecimalSeparator = ".";
return nfi;
} void BeginSection(string Tag)
{
m_tw.WriteLine();
m_tw.WriteLine("SECTION");
m_tw.WriteLine();
m_tw.WriteLine(Tag);
}
void EndSection()
{
m_tw.WriteLine();
m_tw.WriteLine("ENDSEC");
} void EOF()
{
m_tw.WriteLine();
m_tw.WriteLine("EOF");
} void Point(IPointCollection pPoints, string LayerName, byte? Color)
{
for (int i = ; i < pPoints.PointCount; i++)
{
Point(pPoints.get_Point(i), LayerName, Color);
}
} void Blocks()
{
BeginSection(TagDXF.BLOCKS);
EndSection();
} void Tables()
{
BeginSection(TagDXF.TABLES);
EndSection();
} void Point(IPoint pPoint, string LayerName, byte? Color)
{
m_tw.WriteLine();
m_tw.WriteLine("POINT");
m_tw.WriteLine();
m_tw.WriteLine(LayerName);
m_tw.WriteLine();
if (Color != null)
m_tw.WriteLine(Color); m_tw.WriteLine();
m_tw.WriteLine(pPoint.X.ToString(GetFormatProvider()));
m_tw.WriteLine();
m_tw.WriteLine(pPoint.Y.ToString(GetFormatProvider())); m_tw.WriteLine(); //Thickness
m_tw.WriteLine();
} void Header(IEnvelope extent)
{
IPoint LLExtents = extent.LowerLeft;
IPoint URExtents = extent.UpperRight; BeginSection(TagDXF.HEADER); m_tw.WriteLine();
m_tw.WriteLine("$EXTMIN");
m_tw.WriteLine();
m_tw.WriteLine(LLExtents.X.ToString(GetFormatProvider()));
m_tw.WriteLine();
m_tw.WriteLine(LLExtents.Y.ToString(GetFormatProvider()));
m_tw.WriteLine();
m_tw.WriteLine();
m_tw.WriteLine();
m_tw.WriteLine("$EXTMAX");
m_tw.WriteLine();
m_tw.WriteLine(URExtents.X.ToString(GetFormatProvider()));
m_tw.WriteLine();
m_tw.WriteLine(URExtents.Y.ToString(GetFormatProvider()));
m_tw.WriteLine();
m_tw.WriteLine(); EndSection();
} void Polyline(IGeometry pShape, string LayerName, byte? Color)
{ IGeometryCollection geometryCollection; if (pShape is IGeometryCollection)
geometryCollection = pShape as IGeometryCollection;
else
{
object o = Type.Missing;
geometryCollection = new Polygon() as IGeometryCollection;
geometryCollection.AddGeometry(pShape, ref o, ref o);
} for (int j = ; j < geometryCollection.GeometryCount; j++)
{
ISegmentCollection pSegColl = geometryCollection.get_Geometry(j) as ISegmentCollection; bool bFirstSeg = true;
ICircularArc pCA = null;
ISegment pSeg = null; for (int i = ; i < pSegColl.SegmentCount; i++)
{
pSeg = pSegColl.get_Segment(i); switch (pSeg.GeometryType)
{
case esriGeometryType.esriGeometryLine: if (bFirstSeg)
{
m_tw.WriteLine();
m_tw.WriteLine("POLYLINE"); m_tw.WriteLine(); m_tw.WriteLine(LayerName); m_tw.WriteLine();
m_tw.WriteLine(); if (Color != null)
{
m_tw.WriteLine();
m_tw.WriteLine(Color);
}
m_tw.WriteLine();
m_tw.WriteLine("CONTINUOUS");
//from point
m_tw.WriteLine();
m_tw.WriteLine("VERTEX");
m_tw.WriteLine(); m_tw.WriteLine(LayerName); m_tw.WriteLine();
m_tw.WriteLine(pSeg.FromPoint.X.ToString(GetFormatProvider()));
m_tw.WriteLine();
m_tw.WriteLine(pSeg.FromPoint.Y.ToString(GetFormatProvider())); bFirstSeg = !bFirstSeg;
} // to point
m_tw.WriteLine();
m_tw.WriteLine("VERTEX");
m_tw.WriteLine();
m_tw.WriteLine(LayerName); m_tw.WriteLine();
m_tw.WriteLine(pSeg.ToPoint.X.ToString(GetFormatProvider()));
m_tw.WriteLine();
m_tw.WriteLine(pSeg.ToPoint.Y.ToString(GetFormatProvider()));
if (i == (pSegColl.SegmentCount - ))
{
m_tw.WriteLine();
m_tw.WriteLine("SEQEND");
m_tw.WriteLine();
m_tw.WriteLine(LayerName); }
break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryCircularArc:
if (!bFirstSeg)
{ m_tw.WriteLine();
m_tw.WriteLine("SEQEND");
m_tw.WriteLine();
m_tw.WriteLine(LayerName);
} pCA = pSeg as ICircularArc; m_tw.WriteLine();
m_tw.WriteLine("ARC");
m_tw.WriteLine();
m_tw.WriteLine(LayerName);
m_tw.WriteLine();
m_tw.WriteLine(pCA.CenterPoint.X.ToString(GetFormatProvider()));
m_tw.WriteLine();
m_tw.WriteLine(pCA.CenterPoint.Y.ToString(GetFormatProvider()));
m_tw.WriteLine();
m_tw.WriteLine(pCA.Radius); string sFromAngle = (pCA.FromAngle * / Math.PI).ToString(GetFormatProvider());
string sToAngle = (pCA.ToAngle * / Math.PI).ToString(GetFormatProvider()); m_tw.WriteLine();
m_tw.WriteLine(pCA.IsCounterClockwise ? sFromAngle : sToAngle);
m_tw.WriteLine();
m_tw.WriteLine(pCA.IsCounterClockwise ? sToAngle : sFromAngle); bFirstSeg = true;
break;
}
}
}
} void Polygon(IGeometry pShape, string LayerName, byte? Color)
{
IPolygon4 polygon = pShape as IPolygon4;
IGeometryBag exteriorRings = polygon.ExteriorRingBag; //For each exterior rings find the interior rings associated with it
IEnumGeometry exteriorRingsEnum = exteriorRings as IEnumGeometry;
exteriorRingsEnum.Reset();
IRing currentExteriorRing = exteriorRingsEnum.Next() as IRing; while (currentExteriorRing != null)
{
Polyline(currentExteriorRing, LayerName, Color); IGeometryBag interiorRings = polygon.get_InteriorRingBag(currentExteriorRing);
IEnumGeometry interiorRingsEnum = interiorRings as IEnumGeometry;
interiorRingsEnum.Reset();
IRing currentInteriorRing = interiorRingsEnum.Next() as IRing;
while (currentInteriorRing != null)
{
Polyline(currentInteriorRing, LayerName, Color);
currentInteriorRing = interiorRingsEnum.Next() as IRing;
}
currentExteriorRing = exteriorRingsEnum.Next() as IRing;
}
} void Entities()
{
BeginSection(TagDXF.ENTITIES); byte? Color = ;
string LayerName = m_FeatureLayer.Name; IFeatureClass featureClass = m_FeatureLayer.FeatureClass;
IFeatureCursor featureCursor = featureClass.Search(null, true);
IFeature feature = featureCursor.NextFeature();
IGeometry shape = null; while (feature != null)
{
shape = feature.ShapeCopy;
//int? OID = feature.HasOID ? feature.OID : new Nullable<int>(); switch (shape.GeometryType)
{
case esriGeometryType.esriGeometryPoint:
Point(shape as IPoint, LayerName, Color);
break;
case esriGeometryType.esriGeometryMultipoint:
Point(shape as IPointCollection, LayerName, Color);
break;
case esriGeometryType.esriGeometryPolyline:
Polyline(shape, LayerName, Color);
break;
case esriGeometryType.esriGeometryPolygon:
Polygon(shape, LayerName, Color);
break;
case esriGeometryType.esriGeometryEnvelope:
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPath:
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryAny:
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryRing:
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryLine:
Polyline(shape, LayerName, Color);
break;
case esriGeometryType.esriGeometryCircularArc:
case esriGeometryType.esriGeometryBezier3Curve:
case esriGeometryType.esriGeometryEllipticArc:
break;
}
feature = featureCursor.NextFeature();
}
EndSection();
EOF();
}
}
}

转为DXF文件

  至此,WEB直接导入导出SHP/CAD如愿实现,共勉。

  【转载请说明出处,尊重知识传播】2017-06-30

Web直接导入导出SHP/CAD实现探讨。的更多相关文章

  1. PostGIS导入导出SHP文件常用命令

    SHP导入POSTGIS数据库 引用 直接导入数据库 shp2pgsql  -I -s 2437 -W GBK shop_point.shp public.ntable | psql -U postg ...

  2. asp.net core web的导入导出excel功能

    这里主要记录下asp.net core web页面上进行导入导出excel的操作. 主要是导入,因为现在使用的很多前端框架(例如kendo ui)本身就有导出的功能. 这里使用到EPPlus.Core ...

  3. 土制Excel导入导出及相关问题探讨

    转载请注明出处https://www.cnblogs.com/funnyzpc/p/10392085.html 新的一年,又一个开始,不见收获,却见年龄,好一个猪年,待我先来一首里尔克的诗: < ...

  4. WEB 报表导入导出操作

    /** * 报表导出 * @param response */ @RequestMapping("/stuExcel") @LogAnno(value="对学生数据进行了 ...

  5. 宣布发布 Windows Azure 导入/导出服务的预览版以及 Web 和移动解决方案场景的若干增强功能

    客户评估基于云的存储解决方案时,面临的挑战之一是以经济高效.安全快速的方式从 Blob 存储区移进和移出大量数据.今天,我们很高兴地宣布发布 Windows Azure 导入/导出的预览版,这款新服务 ...

  6. ArcGIS连带文字注记导出为CAD格式

    可以使用ArcGIS的"Export To CAD"工具将点.线.面等要素直接导出为CAD格式.如果要连带将ArcGIS中的文字标注导出为CAD格式要稍麻烦一点,下面是一个例子. ...

  7. [转]Office导入导出组件权限配置汇总

    原文地址:Office导入导出组件权限配置汇总 具体配置方法如下:  1:在服务器上安装office的Excel软件.  2:在"开始"->"运行"中输入 ...

  8. ITTC数据挖掘平台介绍(五) 数据导入导出向导和报告生成

    一. 前言 经过了一个多月的努力,软件系统又添加了不少新功能.这些功能包括非常实用的数据导入导出,对触摸进行优化的画布和画笔工具,以及对一些智能分析的报告生成模块等.进一步加强了平台系统级的功能. 马 ...

  9. ASP.NET Core 导入导出Excel xlsx 文件

    ASP.NET Core 使用EPPlus.Core导入导出Excel xlsx 文件,EPPlus.Core支持Excel 2007/2010 xlsx文件导入导出,可以运行在Windows, Li ...

随机推荐

  1. poj1847 Tram 最短路Dijkstra

    题目链接:http://poj.org/problem?id=1847 Dijkstra算法的模版应用 题意:给你N个点和起点终点,点与点有铁路,接下来的N行分别为点i的情况 第一个数字表示与该点连通 ...

  2. 无分类编址(CIDR)构成超网

    CIDR(无分类域间路由选择) CIDR最主要有两个以下特点: 消除传统的A,B,C地址和划分子网的概念,更有效的分配IPv4的地址空间,CIDR使IP地址又回到无分类的两级编码.记法:IP地址::= ...

  3. POJ1182食物链(并查集)

    Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到 ...

  4. shell群发邮件脚本

    linux版本:CentOS  6.7        //可以使用lsb_release -a查看 一.修改/etc/mail.rc set from=123456@qq.com //你自己的真实邮箱 ...

  5. java 学习笔记1 java语言概述及开发环境

    高级语言运行机制 高级语言按程序的执行方式分为编译型和解释型两种. java语言比较特殊,Java程序的执行必须经过先编译后解释的步骤. 1 编译生成字节码,只面向JVM(.class) 2Jvm执行 ...

  6. Adobe After Effect CC2017 for Mac

    前段时间学习使用 Lottie 制作炫酷的动画,需要 Adobe After Effect 安装 bodymovin 插件,然后导出动画的 json 文件.尝试安装 AE 工具.网上查找 史蒂芬周的博 ...

  7. Spring Boot 负载均衡之外置session状态保存

    在使用spring boot做负载均衡的时候,多个app之间的session要保持一致,这样负载到不同的app时候,在一个app登录之后,而打到另外一台服务器的时候,session丢失. 常规的解决方 ...

  8. AngularJS语法基础及数据绑定——详解各种数据绑定指令、属性应用

    AngularJS简单易学,但是功能强大.特别是在构建单页面应用方面效果显著.而 数据绑定 可以说是他被广泛使用的最主要的优点.他舍弃了对DOM的操作方式,一切都由AngularJS来自动更新视图,我 ...

  9. 从零开始的JS生活(一)——JS简介、变量及基本结构

    本K在经过三个静态站制作的狂风暴雨之后,终于开始了JavaScript的学习.作为一只从来没有正儿八经接受过计算机语言的小白,居然能够跟上浩哥的课程进度,我的内心都被我的才智震惊到了,果然本K是天生丽 ...

  10. mysql之 mysql 5.6不停机主从搭建(一主一从)

    环境说明:版本 version 5.6.25-log 主库ip: 10.219.24.25从库ip:10.219.24.22os 版本: centos 6.7已安装热备软件:xtrabackup 防火 ...