📄 placename.cs
字号:
lstps.ShowAtStartup = true;
lstps.MinimumDisplayAltitude = 0;
lstps.MaximumDisplayAltitude = 25000;
lstps.PlacenameListFilePath = @"Data\Earth\Placenames\uscities0\ww.wpl";
lstps.WinColorName = "Yellow";
alTiledPlacenameSet.Add(lstps);
//US Water Features
lstps = new LayerSetTiledPlacenameSet();
lstps.ShowAtStartup = true;
lstps.MinimumDisplayAltitude = 0;
lstps.MaximumDisplayAltitude = 20000;
lstps.PlacenameListFilePath = @"Data\Earth\Placenames\us_water\ww.wpl";
lstps.WinColorName = "Cyan";
alTiledPlacenameSet.Add(lstps);
//US Terrain Features
lstps = new LayerSetTiledPlacenameSet();
lstps.ShowAtStartup = true;
lstps.MinimumDisplayAltitude = 0;
lstps.MaximumDisplayAltitude = 20000;
lstps.PlacenameListFilePath = @"Data\Earth\Placenames\us_terrain\ww.wpl";
lstps.WinColorName = "Orange";
alTiledPlacenameSet.Add(lstps);
//US Anthropogenic Features
lstps = new LayerSetTiledPlacenameSet();
lstps.ShowAtStartup = true;
lstps.MinimumDisplayAltitude = 0;
lstps.MaximumDisplayAltitude = 10000;
lstps.PlacenameListFilePath = @"Data\Earth\Placenames\us_anthropogenic\ww.wpl";
lstps.WinColorName = "Yellow";
alTiledPlacenameSet.Add(lstps);
//GeoNET Populated Place
lstps = new LayerSetTiledPlacenameSet();
lstps.ShowAtStartup = false;
lstps.MinimumDisplayAltitude = 0;
lstps.MaximumDisplayAltitude = 100000;
lstps.PlacenameListFilePath = @"Data\Earth\Placenames\GEONET_p_ppl\ww.wpl";
lstps.WinColorName = "Pink";
alTiledPlacenameSet.Add(lstps);
//Hooters
lstps = new LayerSetTiledPlacenameSet();
lstps.ShowAtStartup = true;
lstps.MinimumDisplayAltitude = 0;
lstps.MaximumDisplayAltitude = 500000;
lstps.PlacenameListFilePath = @"Data\Earth\Placenames\Hooters\ww.wpl";
lstps.WinColorName = "Orange";
alTiledPlacenameSet.Add(lstps);
LayerSetTiledPlacenameSet[] lstpsa = new LayerSetTiledPlacenameSet[alTiledPlacenameSet.Count];
alTiledPlacenameSet.CopyTo(lstpsa);
ls.TiledPlacenameSet = lstpsa;
return ls;
}
#endregion
public void InitializeVertex(Device device)
{
alPlaceLists = new List<PlaceList>();
uint memStart = GetAvailMem();
//GetLayerSetXs(); //about a meg?
LayerSet ls = GetLayerSet();
uint memXs = GetAvailMem();
//mem
winFont = new System.Drawing.Font("Arial", 8, FontStyle.Bold);
drawingFont = new Microsoft.WindowsMobile.DirectX.Direct3D.Font(device, winFont);
foreach (LayerSetTiledPlacenameSet lstps in ls.TiledPlacenameSet)
{
if (lstps.ShowAtStartup == false)
continue;
string dataPath = Settings.StorageCard + Path.GetDirectoryName(lstps.PlacenameListFilePath);
dataPath = dataPath + @"\0000_0000.wwp";
if (File.Exists(dataPath) == false)
continue;
PlaceList pl = new PlaceList();
pl.minAlt = (float)lstps.MinimumDisplayAltitude;
pl.maxAlt = (float)lstps.MaximumDisplayAltitude;
switch (lstps.WinColorName)
{
case "Yellow":
pl.color = Color.Yellow;
break;
case "White":
pl.color = Color.White;
break;
case "Brown":
pl.color = Color.Brown;
break;
case "Cyan":
pl.color = Color.Cyan;
break;
case "Pink":
pl.color = Color.Pink;
break;
case "Orange":
pl.color = Color.Orange;
break;
default:
pl.color = Color.White;
break;
}
/*
FontStyle fontStyle = FontStyle.Regular;
if(lstps.DisplayFont.Style != null)
{
if(lstps.DisplayFont.Style.IsBold)
fontStyle = FontStyle.Bold;
if(lstps.DisplayFont.Style.IsItalic)
fontStyle = FontStyle.Italic;
if(lstps.DisplayFont.Style.IsBold && lstps.DisplayFont.Style.IsItalic)
fontStyle = FontStyle.Bold | FontStyle.Italic;
}
else
{
fontStyle = FontStyle.Regular;
}
*/
//pl.winFont = new System.Drawing.Font("Arial", lstps.DisplayFont.Size, fontStyle);
//pl.drawingFont = new Microsoft.WindowsMobile.DirectX.Direct3D.Font(device, pl.winFont);
FileInfo dataFileInfo = new FileInfo(dataPath);
FileStream dataFileStream = dataFileInfo.OpenRead();
BinaryReader dataFileReader = new BinaryReader(dataFileStream, System.Text.Encoding.ASCII);
int numberPlacenames = dataFileReader.ReadInt32();
for (int j = 0; j < numberPlacenames; j++)
{
Place p = new Place();
p.name = dataFileReader.ReadString();
p.lat = dataFileReader.ReadSingle();
p.lon = dataFileReader.ReadSingle();
int c = dataFileReader.ReadInt32();
//System.Collections.Hashtable metaData = new System.Collections.Hashtable(c);
for (int n = 0; n < c; n++)
{
string key = dataFileReader.ReadString();
string keyData = dataFileReader.ReadString();
//metaData.Add(key, keyData);
}
// for easier hit testing
//float lonRanged = lon;
//if (lonRanged < west)
// lonRanged += 360; // add a revolution
//if (lat <= north && lat >= south && lonRanged <= east && lonRanged >= west)
//{
//WorldWindPlacename pn = new WorldWindPlacename();
//float Lat = lat;
//float Lon = lon;
//string Name = name;
//richTextBox1.AppendText(Name + "\r\n");
//pn.metaData = metaData;
p.point = MathEngine.SphericalToCartesian(p.lat, p.lon, Settings.Radius);
pl.places.Add(p);
//tempPlacenames.Add(pn);
//}
//dataFile.AddPlacename(name, lat, lon);
//adjust for hit testing
p.lat = p.lat + 90;
p.lon = p.lon + 180;
}
alPlaceLists.Add(pl);
dataFileReader.Close();
dataFileStream.Close();
}
}
public void RenderVertex(Device device, Camera camera)
{
float decViewRange = (float) MathEngine.RadiansToDegrees(camera.ViewRange) / 4f; //not quire 1/2
float north = (camera.Latitude + 90) + decViewRange;
float east = (camera.Longitude + 180) + decViewRange;
float south = (camera.Latitude + 90) - decViewRange;
float west = (camera.Longitude + 180) - decViewRange;
foreach (PlaceList pl in alPlaceLists)
{
if (camera.Altitude > pl.minAlt && camera.Altitude < pl.maxAlt)
{
foreach (Place p in pl.places)
{
if (p.lat <= north && p.lat >= south && p.lon <= east && p.lon >= west)
{
Vector3 v = p.point;
v.Project(device.Viewport, camera.Projection, camera.View, camera.World);
//pl.drawingFont.DrawText(null, p.name, new System.Drawing.Rectangle((int)p.point.X, (int)p.point.Y, device.Viewport.Width, device.Viewport.Height), DrawTextFormat.WordBreak | DrawTextFormat.NoClip, pl.color);
drawingFont.DrawText(null, p.name, new System.Drawing.Rectangle((int)v.X, (int)v.Y, device.Viewport.Width, device.Viewport.Height), DrawTextFormat.WordBreak | DrawTextFormat.NoClip, pl.color);
}
}
}
}
}
public Place[] FindPlace(string name)
{
name = name.ToLower();
List<Place> alPossible = new List<Place>();
foreach (PlaceList pl in alPlaceLists)
{
int index = -1;
foreach (Place p in pl.places)
{
//int result = string.Compare(name, p.name, true);
//if (result == 0)
//{
// alPossible.Add(p);
//}
index = p.name.ToLower().IndexOf(name);
if (index != -1)
{
alPossible.Add(p);
}
}
}
Place[] pa = new Place[alPossible.Count];
alPossible.CopyTo(pa);
return pa;
}
public void Dispose()
{
if (drawingFont != null)
{
drawingFont.Dispose();
drawingFont = null;
}
if (alPlaceLists != null)
{
alPlaceLists.Clear();
alPlaceLists = null;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -