添加塔号
This commit is contained in:
parent
a109aa6836
commit
d63983fa43
|
|
@ -33,6 +33,14 @@ namespace PutTowerPosition
|
||||||
public double X;
|
public double X;
|
||||||
public double Y;
|
public double Y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Position
|
||||||
|
{
|
||||||
|
public double X;
|
||||||
|
public double Y;
|
||||||
|
public string towerName;
|
||||||
|
}
|
||||||
|
|
||||||
[CommandMethod("ptp", CommandFlags.Session)]
|
[CommandMethod("ptp", CommandFlags.Session)]
|
||||||
public static void PutTowerPositionCmd()
|
public static void PutTowerPositionCmd()
|
||||||
{
|
{
|
||||||
|
|
@ -67,8 +75,8 @@ namespace PutTowerPosition
|
||||||
|
|
||||||
OpenMode.ForWrite) as BlockTableRecord;
|
OpenMode.ForWrite) as BlockTableRecord;
|
||||||
|
|
||||||
Point2D[] cordinationList = calTowerXYPostion(cordDic, spanList);
|
Position[] cordinationList = calTowerXYPostion(cordDic, spanList);
|
||||||
foreach (Point2D point in cordinationList)
|
foreach (Position point in cordinationList)
|
||||||
{
|
{
|
||||||
DBPoint dbPoint = new DBPoint(new Point3d(point.Y, point.X, 0));
|
DBPoint dbPoint = new DBPoint(new Point3d(point.Y, point.X, 0));
|
||||||
dbPoint.Layer = "TW";
|
dbPoint.Layer = "TW";
|
||||||
|
|
@ -76,8 +84,14 @@ namespace PutTowerPosition
|
||||||
acTrans.AddNewlyCreatedDBObject(dbPoint, true);
|
acTrans.AddNewlyCreatedDBObject(dbPoint, true);
|
||||||
acCurDb.Pdmode = 35;
|
acCurDb.Pdmode = 35;
|
||||||
acCurDb.Pdsize = 15;
|
acCurDb.Pdsize = 15;
|
||||||
|
DBText dbTowerName=new DBText();
|
||||||
//break;
|
dbTowerName.TextString = point.towerName;
|
||||||
|
Point3d towerNamePoint = new Point3d(point.Y + 20, point.X + 20,0);
|
||||||
|
dbTowerName.Position = towerNamePoint;
|
||||||
|
dbTowerName.Layer = "TW";
|
||||||
|
dbTowerName.Height = 40;
|
||||||
|
acBlkTblRec.AppendEntity(dbTowerName);
|
||||||
|
acTrans.AddNewlyCreatedDBObject(dbTowerName,true);
|
||||||
}
|
}
|
||||||
acTrans.Commit();
|
acTrans.Commit();
|
||||||
}
|
}
|
||||||
|
|
@ -292,9 +306,9 @@ namespace PutTowerPosition
|
||||||
return spanList;
|
return spanList;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Point2D[] calTowerXYPostion(Dictionary<string, double[]> cordDic, List<spanStruct> SSpan)
|
static Position[] calTowerXYPostion(Dictionary<string, double[]> cordDic, List<spanStruct> SSpan)
|
||||||
{
|
{
|
||||||
Point2D[] cordinationList = new Point2D[SSpan.Count];
|
Position[] cordinationList = new Position[SSpan.Count];
|
||||||
Point2D startPoint;
|
Point2D startPoint;
|
||||||
int tensionStart;//耐张段第一基塔位置
|
int tensionStart;//耐张段第一基塔位置
|
||||||
tensionStart = 0;
|
tensionStart = 0;
|
||||||
|
|
@ -302,29 +316,38 @@ namespace PutTowerPosition
|
||||||
Point2D endPoint;
|
Point2D endPoint;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
Position startPosition;
|
||||||
startPoint.X = cordDic[SSpan[tensionStart].towerName][0];
|
startPoint.X = cordDic[SSpan[tensionStart].towerName][0];
|
||||||
startPoint.Y = cordDic[SSpan[tensionStart].towerName][1];
|
startPoint.Y = cordDic[SSpan[tensionStart].towerName][1];
|
||||||
|
startPosition.towerName = SSpan[tensionStart].towerName;
|
||||||
|
startPosition.X = startPoint.X;
|
||||||
|
startPosition.Y = startPoint.Y;
|
||||||
|
cordinationList[tensionStart] = startPosition;
|
||||||
for (int i = tensionStart+1; i < SSpan.Count; i++)
|
for (int i = tensionStart+1; i < SSpan.Count; i++)
|
||||||
{
|
{
|
||||||
string towerName;
|
string endTowerName;
|
||||||
towerName = SSpan[i].towerName;
|
endTowerName = SSpan[i].towerName;
|
||||||
if (cordDic.ContainsKey(towerName))
|
if (cordDic.ContainsKey(endTowerName))
|
||||||
{
|
{
|
||||||
endPoint.X = cordDic[towerName][0];
|
endPoint.X = cordDic[endTowerName][0];
|
||||||
endPoint.Y = cordDic[towerName][1];
|
endPoint.Y = cordDic[endTowerName][1];
|
||||||
cordinationList[tensionStart] = startPoint;
|
|
||||||
double mileageInTension=0;//耐张段中的里程
|
double mileageInTension=0;//耐张段中的里程
|
||||||
for (int j = tensionStart + 1; j < i; j++)
|
for (int j = tensionStart + 1; j < i; j++)
|
||||||
{
|
{
|
||||||
Point2D suspensionTowerPostion;
|
Position suspensionTowerPostion;
|
||||||
double tensionLength;//耐张段长度
|
double tensionLength;//耐张段长度
|
||||||
tensionLength = Math.Sqrt(Math.Pow(endPoint.X - startPoint.X, 2) + Math.Pow(endPoint.Y - startPoint.Y, 2));
|
tensionLength = Math.Sqrt(Math.Pow(endPoint.X - startPoint.X, 2) + Math.Pow(endPoint.Y - startPoint.Y, 2));
|
||||||
mileageInTension += SSpan[j].span;
|
mileageInTension += SSpan[j].span;
|
||||||
suspensionTowerPostion.X = startPoint.X + (endPoint.X - startPoint.X) / tensionLength * mileageInTension;
|
suspensionTowerPostion.X = startPoint.X + (endPoint.X - startPoint.X) / tensionLength * mileageInTension;
|
||||||
suspensionTowerPostion.Y = startPoint.Y + (endPoint.Y - startPoint.Y) / tensionLength * mileageInTension;
|
suspensionTowerPostion.Y = startPoint.Y + (endPoint.Y - startPoint.Y) / tensionLength * mileageInTension;
|
||||||
|
suspensionTowerPostion.towerName = SSpan[j].towerName;
|
||||||
cordinationList[j]=suspensionTowerPostion;
|
cordinationList[j]=suspensionTowerPostion;
|
||||||
}
|
}
|
||||||
cordinationList[i] = endPoint;
|
Position endPosition;
|
||||||
|
endPosition.X = endPoint.X;
|
||||||
|
endPosition.Y = endPoint.Y;
|
||||||
|
endPosition.towerName = endTowerName;
|
||||||
|
cordinationList[i] = endPosition;
|
||||||
tensionStart = i;
|
tensionStart = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue