• R/O
  • SSH
  • HTTPS

wheretrainbuild: Commit


Commit MetaInfo

Revision48 (tree)
Zeit2020-06-29 01:40:45
Autordangerouswoo

Log Message

(empty log message)

Ändern Zusammenfassung

Diff

--- WhereTrainBuild/AI/LineWalker.cs (revision 47)
+++ WhereTrainBuild/AI/LineWalker.cs (revision 48)
@@ -163,24 +163,32 @@
163163 {
164164 var findlist = new List<ThreshPack>();
165165
166- for (float fDistance = 2.0f; fDistance <= 50.0f; fDistance += 2.0f)
166+ for (float fDistance = 2.0f; fDistance <= 60.0f; fDistance += 4.0f)
167167 {
168- (bool Result, latlontool.latlng next) result;
169-
170168 double dDeltaR = 1 / fDistance * 2.0;
171169
172170 //とりあえず、前方向をサーチ
171+ List<double> loopsrc = new List<double>();
173172 for (double iD = -40.0; iD <= 40.0; iD += dDeltaR)
173+ loopsrc.Add(iD);
174+
175+ Parallel.ForEach(loopsrc, (iD) =>
174176 {
175177 var vdo = latlontool.ToRadian(latlontool.ToAngle(Math.Atan2(nvector.Y, nvector.X)) + iD);
176178 var testvector = new PointF((float)Math.Cos(vdo), (float)Math.Sin(vdo));
177- result = Move(nlatlng, testvector, fDistance);
179+ var result = Move(nlatlng, testvector, fDistance);
178180 if (result.Result == true)
179181 {
180- //発見
181- findlist.Add(new ThreshPack() { Position = result.next, Vector = testvector, AngleDiff = iD , Distance = fDistance });
182+ lock (findlist)
183+ {
184+ //発見
185+ findlist.Add(new ThreshPack() { Position = result.next, Vector = testvector, AngleDiff = iD, Distance = fDistance });
186+ }
182187 }
183- }
188+ });
189+
190+ if (findlist.Count > 0 && fDistance > 30.0f)
191+ break;
184192 }
185193
186194 if (findlist.Count <= 0)
@@ -304,31 +312,35 @@
304312 iTileY++;
305313 }
306314
307- MapTile maptile = null;
308- if (m_cache.ContainsKey(MapTile.MakeKey(iTileX, iTileY, m_zoom)) == false)
315+ Color color;
316+
317+ lock (this)
309318 {
310- maptile = m_maptilemanager.GetMapTile(iTileX, iTileY, m_zoom);
311- if (maptile == null)
312- maptile = m_maptilemanager.BuildMapTile(iTileX, iTileY, m_zoom);
313- if (maptile != null)
314- m_cache[MapTile.MakeKey(iTileX, iTileY, m_zoom)] = maptile;
315- }
316- else
317- maptile = m_cache[MapTile.MakeKey(iTileX, iTileY, m_zoom)];
319+ MapTile maptile = null;
320+ if (m_cache.ContainsKey(MapTile.MakeKey(iTileX, iTileY, m_zoom)) == false)
321+ {
322+ maptile = m_maptilemanager.GetMapTile(iTileX, iTileY, m_zoom);
323+ if (maptile == null)
324+ maptile = m_maptilemanager.BuildMapTile(iTileX, iTileY, m_zoom);
325+ if (maptile != null)
326+ m_cache[MapTile.MakeKey(iTileX, iTileY, m_zoom)] = maptile;
327+ }
328+ else
329+ maptile = m_cache[MapTile.MakeKey(iTileX, iTileY, m_zoom)];
318330
319- var image = maptile.GetImage() as Bitmap;
320- if( image == null )
321- {
322- image = maptile.GetImage(m_maptilemanager.BaseFolder, m_maptilemanager.Timeout) as Bitmap;
331+ var image = maptile.GetImage() as Bitmap;
332+ if (image == null)
333+ {
334+ image = maptile.GetImage(m_maptilemanager.BaseFolder, m_maptilemanager.Timeout) as Bitmap;
335+ }
336+ if (image == null)
337+ {
338+ return (Result: false, next: pnt);
339+ }
340+ //画像取得
341+ color = image.GetPixel((int)x, (int)y);
323342 }
324- if (image == null)
325- {
326- return (Result: false, next: pnt);
327- }
328343
329- //画像取得
330- var color = image.GetPixel((int)x, (int)y);
331-
332344 //判定
333345 var weight = TileAnalyzer3.Weight(color, Color.FromArgb(255, 109, 15, 15));
334346 if (weight > 0.7f)
Show on old repository browser