feat: 初始化 fl-knowledge 仓库 - 防雷项目源码

This commit is contained in:
chengkai3
2026-06-06 08:03:01 +08:00
commit 3726b404c4
99 changed files with 44754 additions and 0 deletions
+451
View File
@@ -0,0 +1,451 @@
using System;
using System.Collections.Generic;
using System.IO;
using AxMapWinGIS;
using MapWinGIS;
namespace LP;
public class DisplayAllXianLu
{
public List<DisplayGanTaIn1XianLu> mListDisplayXianLu = null;
private double minJingDu;
private double maxJingDu;
private double minWeiDu_;
private double maxWeiDu_;
private double minM_JingDu;
private double maxM_JingDu;
private double minM_WeiDu_;
private double maxM_WeiDu_;
private double maxXY_m;
public int mNumShowXianLus = 0;
public string mFileName_province = "";
public Image mImage = null;
public Shapefile mShapefile = null;
public int mLayerHandle = -1;
public DisplayAllXianLu()
{
if (mListDisplayXianLu == null)
{
mListDisplayXianLu = new List<DisplayGanTaIn1XianLu>();
}
MyClear();
}
public void MyClear()
{
if (mListDisplayXianLu == null)
{
mListDisplayXianLu = new List<DisplayGanTaIn1XianLu>();
}
for (int i = 0; i < mListDisplayXianLu.Count; i++)
{
if (mListDisplayXianLu[i] != null)
{
mListDisplayXianLu[i].MyClear();
mListDisplayXianLu[i] = null;
}
}
mListDisplayXianLu.Clear();
mNumShowXianLus = 0;
}
public void Destroy()
{
if (mListDisplayXianLu != null)
{
MyClear();
}
mListDisplayXianLu = null;
}
public void Add1XianLu_JingDu_WeiDu(List<double> _listJingDu, List<double> _listWeiDu, int _idXianLu)
{
DisplayGanTaIn1XianLu _oneDisplayXianLu = new DisplayGanTaIn1XianLu();
_oneDisplayXianLu.MyClear();
for (int i = 0; i < _listJingDu.Count && i < _listWeiDu.Count; i++)
{
_oneDisplayXianLu.Add1Point_JingDu_WeiDu(_listJingDu[i], _listWeiDu[i]);
}
_oneDisplayXianLu.MySet_XianLuID(_idXianLu);
MyAdd_listDisplayXianLu(ref _oneDisplayXianLu);
}
private void MyAdd_listDisplayXianLu(ref DisplayGanTaIn1XianLu _oneDisplayXianLu)
{
mListDisplayXianLu.Add(_oneDisplayXianLu);
mNumShowXianLus++;
}
public string MyInfor_JingDu_WeiDu()
{
string text = "";
for (int i = 0; i < mListDisplayXianLu.Count; i++)
{
if (mListDisplayXianLu[i] == null || mListDisplayXianLu[i].mNumShowGanTas == 0)
{
continue;
}
if (i > 0)
{
text += " ";
}
text += $"id={mListDisplayXianLu[i].MyGet_XianLuID()}[";
for (int j = 0; j < mListDisplayXianLu[i].mNumShowGanTas && j < mListDisplayXianLu[i].mListJingDu.Count && j < mListDisplayXianLu[i].mListWeiDu.Count; j++)
{
if (j > 0)
{
text += " ";
}
text += $"({mListDisplayXianLu[i].mListJingDu[j]},{mListDisplayXianLu[i].mListWeiDu[j]})";
}
text += "]";
text += "[";
for (int k = 0; k < mListDisplayXianLu[i].mNumShowGanTas && k < mListDisplayXianLu[i].mListX_m.Count && k < mListDisplayXianLu[i].mListY_m.Count; k++)
{
if (k > 0)
{
text += " ";
}
text += $"({mListDisplayXianLu[i].mListX_m[k]},{mListDisplayXianLu[i].mListY_m[k]})";
}
text += "]";
}
return text;
}
public void MyMinMax_JingWeiDu()
{
minJingDu = (maxJingDu = (minWeiDu_ = (maxWeiDu_ = 0.0)));
minJingDu = 73.55;
maxJingDu = 130.083333;
minWeiDu_ = 18.166667;
maxWeiDu_ = 54.616667;
minM_JingDu = -2600000.0;
maxM_JingDu = 2100000.0;
minM_WeiDu_ = 2400000.0;
maxM_WeiDu_ = 6400000.0;
}
public void MyBuildXY()
{
int num = 0;
int num2 = 0;
double num3 = 0.0;
if (mListDisplayXianLu == null)
{
return;
}
for (int i = 0; i < mNumShowXianLus && i < mListDisplayXianLu.Count; i++)
{
if (mListDisplayXianLu[i] == null)
{
continue;
}
num = 0;
if (mListDisplayXianLu[i].mListJingDu == null || mListDisplayXianLu[i].mListWeiDu == null)
{
continue;
}
for (int j = 0; j < mListDisplayXianLu[i].mNumShowGanTas && j < mListDisplayXianLu[i].mListJingDu.Count && j < mListDisplayXianLu[i].mListWeiDu.Count; j++)
{
if (num == 0)
{
if (mListDisplayXianLu[i].mListX_m == null)
{
mListDisplayXianLu[i].mListX_m = new List<double>();
}
if (mListDisplayXianLu[i].mListY_m == null)
{
mListDisplayXianLu[i].mListY_m = new List<double>();
}
mListDisplayXianLu[i].mListX_m.Clear();
mListDisplayXianLu[i].mListY_m.Clear();
}
num++;
num2++;
double num4 = (mListDisplayXianLu[i].mListJingDu[j] - minJingDu) / (maxJingDu - minJingDu) * (maxM_JingDu - minM_JingDu) + minM_JingDu;
mListDisplayXianLu[i].mListX_m.Add(num4);
if (num2 == 1)
{
num3 = num4;
}
if (num2 > 1 && num3 < num4)
{
num3 = num4;
}
num4 = (mListDisplayXianLu[i].mListWeiDu[j] - minWeiDu_) / (maxWeiDu_ - minWeiDu_) * (maxM_WeiDu_ - minM_WeiDu_) + minM_WeiDu_;
mListDisplayXianLu[i].mListY_m.Add(num4);
if (num3 < num4)
{
num3 = num4;
}
}
}
maxXY_m = num3;
}
private Shapefile CreateLines_JingDu_WeiDu(DisplayGanTaIn1XianLu _displayXianLu)
{
Shapefile shapefile = null;
if (shapefile == null)
{
shapefile = new ShapefileClass();
}
shapefile.CreateNew("", ShpfileType.SHP_POLYLINEM);
Shape shape = new ShapeClass();
shape.Create(ShpfileType.SHP_POLYLINEM);
Point point = null;
int num = 0;
for (int i = 0; i < _displayXianLu.mNumShowGanTas; i++)
{
point = new PointClass();
point.x = _displayXianLu.mListX_m[i];
point.y = _displayXianLu.mListY_m[i];
num = shape.numPoints;
shape.InsertPoint(point, ref num);
}
num = shapefile.NumShapes;
shapefile.EditInsertShape(shape, ref num);
return shapefile;
}
public Shapefile CreateLines(DisplayGanTaIn1XianLu _displayXianLu)
{
Shapefile shapefile = null;
if (shapefile == null)
{
shapefile = new ShapefileClass();
}
shapefile.CreateNew("", ShpfileType.SHP_POLYLINE);
Shape shape = new ShapeClass();
shape.Create(ShpfileType.SHP_POLYLINE);
Point point = null;
int num = 0;
for (int i = 0; i < _displayXianLu.mNumShowGanTas; i++)
{
if (i < _displayXianLu.mListX_m.Count && i < _displayXianLu.mListY_m.Count)
{
point = new PointClass();
point.x = _displayXianLu.mListX_m[i];
point.y = _displayXianLu.mListY_m[i];
num = shape.numPoints;
shape.InsertPoint(point, ref num);
}
}
num = shapefile.NumShapes;
shapefile.EditInsertShape(shape, ref num);
return shapefile;
}
public Shapefile CreateGanTas(DisplayGanTaIn1XianLu _displayXianLu)
{
Shapefile shapefile = null;
if (shapefile == null)
{
shapefile = new ShapefileClass();
}
shapefile.CreateNewWithShapeID("", ShpfileType.SHP_POINT);
Point point = null;
for (int i = 0; i < _displayXianLu.mNumShowGanTas; i++)
{
if (i < _displayXianLu.mListX_m.Count && i < _displayXianLu.mListY_m.Count)
{
point = new PointClass();
point.x = _displayXianLu.mListX_m[i];
point.y = _displayXianLu.mListY_m[i];
Shape shape = new ShapeClass();
shape.Create(ShpfileType.SHP_POINT);
int pointIndex = 0;
shape.InsertPoint(point, ref pointIndex);
shapefile.EditInsertShape(shape, ref i);
}
}
shapefile.DefaultDrawingOptions.SetDefaultPointSymbol(tkDefaultPointSymbol.dpsCircle);
return shapefile;
}
public void MyLinesPattern(FormDesktop _desktop, ref AxMap axMap1)
{
axMap1.RemoveAllLayers();
axMap1.LockWindow(tkLockMode.lmLock);
if (mLayerHandle >= 0)
{
axMap1.RemoveLayer(mLayerHandle);
mLayerHandle = -1;
mShapefile = null;
}
try
{
axMap1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
if (mShapefile == null && _desktop.mSignal.mShow_Province)
{
mShapefile = new ShapefileClass();
if (File.Exists(mFileName_province))
{
if (mShapefile.Open(mFileName_province))
{
mLayerHandle = axMap1.AddLayer(mShapefile, visible: true);
}
else
{
MyLog.AddLog("MyLinesPattern() " + ((IShapefile)mShapefile).get_ErrorMsg(mShapefile.LastErrorCode));
}
}
else
{
MyLog.AddLog("MyLinesPattern() file not found. " + mFileName_province);
}
}
for (int i = 0; i < mListDisplayXianLu.Count; i++)
{
Shapefile shapefile = CreateLines(mListDisplayXianLu[i]);
axMap1.AddLayer(shapefile, visible: true);
Utils utils = new UtilsClass();
LinePattern linePattern = null;
ShapefileCategory shapefileCategory = null;
linePattern = new LinePatternClass();
linePattern.AddLine(utils.ColorByName(tkMapColor.DarkBlue), 6f, tkDashStyle.dsSolid);
linePattern.AddLine(utils.ColorByName(tkMapColor.LightBlue), 4f, tkDashStyle.dsSolid);
shapefileCategory = shapefile.Categories.Add("River");
shapefileCategory.DrawingOptions.LinePattern = linePattern;
shapefileCategory.DrawingOptions.UseLinePattern = true;
((IShapefile)shapefile).set_ShapeCategory(0, 0);
Shapefile shapefile2 = CreateGanTas(mListDisplayXianLu[i]);
axMap1.AddLayer(shapefile2, visible: true);
}
}
catch (Exception ex)
{
MyLog.AddLog("MyLinesPattern() ex=" + ex.Message);
}
finally
{
axMap1.LockWindow(tkLockMode.lmUnlock);
MyLog.AddLog($"MyLinesPattern() Layers added to the map: {axMap1.NumLayers}");
}
}
public void MyLinesPattern_old(FormDesktop _desktop, ref AxMap axMap1)
{
try
{
axMap1.RemoveAllLayers();
axMap1.LockWindow(tkLockMode.lmLock);
if (mLayerHandle >= 0)
{
axMap1.RemoveLayer(mLayerHandle);
mLayerHandle = -1;
mShapefile = null;
}
axMap1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
if (mShapefile == null)
{
mShapefile = new ShapefileClass();
if (File.Exists(mFileName_province))
{
if (mShapefile.Open(mFileName_province))
{
mLayerHandle = axMap1.AddLayer(mShapefile, visible: true);
}
else
{
MyLog.AddLog("MyLinesPattern_old() " + ((IShapefile)mShapefile).get_ErrorMsg(mShapefile.LastErrorCode));
}
}
else
{
MyLog.AddLog("MyLinesPattern_old() file not found. " + mFileName_province);
}
}
LinePattern_old(ref axMap1);
}
catch (Exception ex)
{
MyLog.AddLog("MyLinesPattern_old() ex=" + ex.Message);
}
finally
{
axMap1.LockWindow(tkLockMode.lmUnlock);
MyLog.AddLog($"MyLinesPattern_old() NumLayers={axMap1.NumLayers}");
}
}
private Shapefile CreateLines_old()
{
Shapefile shapefile = null;
if (shapefile == null)
{
shapefile = new ShapefileClass();
}
shapefile.CreateNew("", ShpfileType.SHP_POLYLINE);
int num = 4700000;
int num2 = 2000000;
for (int i = 0; i < 3; i++)
{
Shape shape = new ShapeClass();
shape.Create(ShpfileType.SHP_POLYLINE);
Point point = new PointClass();
point.x = -2600000.0;
point.y = 400000 + (i + 1) * num2;
int pointIndex = shape.numPoints;
shape.InsertPoint(point, ref pointIndex);
point = new PointClass();
point.x = -2600000 + num;
point.y = 400000 + (i + 1) * num2;
pointIndex = shape.numPoints;
shape.InsertPoint(point, ref pointIndex);
pointIndex = shapefile.NumShapes;
shapefile.EditInsertShape(shape, ref pointIndex);
}
return shapefile;
}
public void LinePattern_old(ref AxMap axMap1)
{
axMap1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
Shapefile shapefile = CreateLines_old();
axMap1.AddLayer(shapefile, visible: true);
Utils utils = new UtilsClass();
LinePattern linePattern = new LinePatternClass();
linePattern.AddLine(utils.ColorByName(tkMapColor.Black), 6f, tkDashStyle.dsSolid);
linePattern.AddLine(utils.ColorByName(tkMapColor.White), 5f, tkDashStyle.dsDot);
ShapefileCategory shapefileCategory = shapefile.Categories.Add("Railroad");
shapefileCategory.DrawingOptions.LinePattern = linePattern;
shapefileCategory.DrawingOptions.UseLinePattern = true;
((IShapefile)shapefile).set_ShapeCategory(0, 0);
linePattern = new LinePatternClass();
linePattern.AddLine(utils.ColorByName(tkMapColor.DarkBlue), 6f, tkDashStyle.dsSolid);
linePattern.AddLine(utils.ColorByName(tkMapColor.LightBlue), 4f, tkDashStyle.dsSolid);
shapefileCategory = shapefile.Categories.Add("River");
shapefileCategory.DrawingOptions.LinePattern = linePattern;
shapefileCategory.DrawingOptions.UseLinePattern = true;
((IShapefile)shapefile).set_ShapeCategory(1, 1);
linePattern = new LinePatternClass();
linePattern.AddLine(utils.ColorByName(tkMapColor.Gray), 8f, tkDashStyle.dsSolid);
linePattern.AddLine(utils.ColorByName(tkMapColor.Yellow), 7f, tkDashStyle.dsSolid);
LineSegment lineSegment = linePattern.AddMarker(tkDefaultPointSymbol.dpsArrowRight);
lineSegment.Color = utils.ColorByName(tkMapColor.Orange);
lineSegment.MarkerSize = 10f;
lineSegment.MarkerInterval = 32f;
shapefileCategory = shapefile.Categories.Add("Direction");
shapefileCategory.DrawingOptions.LinePattern = linePattern;
shapefileCategory.DrawingOptions.UseLinePattern = true;
((IShapefile)shapefile).set_ShapeCategory(2, 2);
}
}