public static void InitTestSuite(TestContext testContext) { // simulate previous prefab build airline = new Airline(lat, lon); airline.ResetTRackId(); airline.Build(); highway = new Highway(lat, lon); }
public void Execute(Entity entity, int index, [ReadOnly] ref ColorChangeComponent colorChangeComponent, [ReadOnly] ref ColorComponent colorComponent) { var mesh = Highway.GetRenderMeshes()[colorComponent.Value]; CommandBuffer.SetSharedComponent(index, entity, new RenderMesh() { mesh = mesh.mesh, material = mesh.material }); CommandBuffer.RemoveComponent <ColorChangeComponent>(index, entity); }
// Use this for initialization void Awake() { S = this; m_instantiatedComponents = new List <GameObject>(); GameObject component = GameObject.Instantiate <GameObject>(highwayComponent); component.transform.position = Vector3.zero; component.transform.parent = transform; m_instantiatedComponents.Add(component); }
private void SetupMaterials() { _instance = this; const int materialCount = 10; _renderers = new RenderMesh[materialCount]; for (var i = 0; i < materialCount; i++) { var newMaterial = new Material(baseMaterial); newMaterial.color = color.Evaluate((float)i / materialCount); _renderers[i] = new RenderMesh() { mesh = carMesh, material = newMaterial }; } }
private void saveHighwayConfig() { sceneSave.highwaySaveList = new List <HighwaySave>(); for (int i = 0; i < scene.highwayList.Count; i++) { HighwaySave highwaySave = new HighwaySave(); Highway h = scene.highwayList[i]; highwaySave.highwayID = h.id; highwaySave.hasLeftSidewalk = h.hasLeftSidewalk; highwaySave.hasRightSidewalk = h.hasRightSideWalk; highwaySave.leftSidewalkSize = h.leftSidewalkSize; highwaySave.rightSidewalkSize = h.rightSidewalkSize; highwaySave.waySize = h.waySize; sceneSave.highwaySaveList.Add(highwaySave); } }
public ZenrinParser Load(string selectedFolder) { Highways = new List <Highway>(); Interchanges = new List <Interchange>(); HighwayInterchanges = new List <HighwayInterchange>(); _Folder = new DirectoryInfo(selectedFolder); var targetFiles = _Folder.GetFiles("*.TXT", SearchOption.TopDirectoryOnly).ToList(); var data = new List <InterchangeParsed>(); foreach (var tf in targetFiles) { using (FileStream fs = File.OpenRead(tf.FullName)) using (TextReader reader = new StreamReader(fs, Encoding.GetEncoding("shift_jis"))) { using (var rodadCsv = new CachedCsvReader(reader, false, '\t')) { data.AddRange(rodadCsv.Select((s, i) => { return(new InterchangeRaw { FileName = tf.Name, RowNumber = i + 1, PrefectureCode = s.GetValue(0).ToString(), ZenrinTypeCode = s.GetValue(1).ToString(), PrefectureICSerial = s.GetValue(2).ToString(), HighwayKana = s.GetValue(6).ToString(), IC_Kana = s.GetValue(7).ToString(), HighwayKanji = s.GetValue(8).ToString(), IC_Kanji = s.GetValue(9).ToString(), Longitude = s.GetValue(17).ToString(), Latitude = s.GetValue(18).ToString(), DataDate = s.GetValue(30).ToString(), }.Parse()); }).ToList()); } } } Highways = Highway.ParseHighways(data); Interchanges = Interchange.NormalizedInterchange(Highways); HighwayInterchanges = Interchanges.SelectMany(ic => ic.Highways.Select(h => new { Highway = h.Item1, SortOrder = h.Item2, Interchange = ic })).OrderBy(hi => hi.Highway.TempHighwayId).ThenBy(hi => hi.SortOrder) .Select(i => new HighwayInterchange { Interchange = i.Interchange, SortOrder = i.SortOrder, HighwayKana = i.Highway.HighwayKana, PrefectureCode = i.Highway.PrefectureCode, HighwayKanji = i.Highway.HighwayKanji, TempHighwayId = i.Highway.TempHighwayId }).ToList(); return(this); }
public Highway ReturnTheFirstIntersectionPoint(string road) { Highway start = new Highway(0, 0); Highway[] pieces = { start }; Highway movement = pieces[pieces.Length - 1]; foreach (char item in road) { HighwayMovement(item, ref movement); if (CeckForIntersection(movement, pieces)) { return movement; } else { AddStepsToHighway(ref movement, ref pieces); } } return start; }
public void AddHighway(string s, string d, double w) { Highway h = new Highway(s, d, w); E.Add(h); if (!V.ContainsKey(s)) { V.Add(s, new City()); } if (!V.ContainsKey(d)) { V.Add(d, new City()); } if (!D.ContainsKey(s)) { D.Add(s, new List <Highway>()); } D[s].Add(h); }
public void HighwayMovement(char direction, ref Highway piece) { switch (direction) { case 'U': piece = new Highway(piece.x + 1, piece.y); break; case 'D': piece = new Highway(piece.x - 1, piece.y); break; case 'L': piece = new Highway(piece.x, piece.y - 1); break; case 'R': piece = new Highway(piece.x, piece.y + 1); break; } }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="PathMarker"/> class. /// </summary> /// <param name="mcMapControl">The mc map control.</param> /// <param name="points">The points.</param> /// <param name="h">The h.</param> /// <param name="strToolTip">The string tool tip.</param> public PathMarker(GMapControl mcMapControl, IEnumerable <PointLatLng> points, Highway h, string strToolTip) : base(points) { this.mcMapControl = mcMapControl; this.hType = h; Label label = new Label { Background = Brushes.Yellow, Foreground = Brushes.Black, BorderBrush = Brushes.Black, BorderThickness = new Thickness(2), Padding = new Thickness(3), FontSize = 14, FontFamily = new FontFamily("Courier New"), Content = strToolTip }; this.popup = new Popup { Placement = PlacementMode.Mouse, Child = label }; RegenerateShape(mcMapControl); if (this.Shape is Path path) { path.IsHitTestVisible = true; path.Cursor = Cursors.Cross; } SyncHighwayType(); this.Shape.MouseLeftButtonUp += MarkerControl_MouseLeftButtonUp; this.Shape.MouseLeftButtonDown += MarkerControl_MouseLeftButtonDown; this.Shape.MouseEnter += MarkerControl_MouseEnter; this.Shape.MouseLeave += MarkerControl_MouseLeave; }
public void fillMenu(string highwayID) { fillLock = true; if (highwayEditMenu == null) { highwayEditMenu = GameObject.Find("Canvas").transform.Find("HighwayEdit").gameObject; } if (TThighwayID == null) { TThighwayID = highwayEditMenu.transform.Find("Panel").Find("Text_ID").GetComponent <Text>(); TThighwayType = highwayEditMenu.transform.Find("Panel").Find("Text_Type").GetComponent <Text>(); TThighwayName = highwayEditMenu.transform.Find("Panel").Find("Text_StreetName").GetComponent <Text>(); IFhighwaySize = highwayEditMenu.transform.Find("Panel").Find("InputField_Size").GetComponent <InputField>(); TGleftSidewalk = highwayEditMenu.transform.Find("Panel").Find("ToggleLeft").GetComponent <Toggle>(); TGrightSidewalk = highwayEditMenu.transform.Find("Panel").Find("ToggleRight").GetComponent <Toggle>(); IFleftSidewalkSize = highwayEditMenu.transform.Find("Panel").Find("InputField_LeftSize").GetComponent <InputField>(); IFrightSidewalkSize = highwayEditMenu.transform.Find("Panel").Find("InputField_RightSize").GetComponent <InputField>(); } if (loadSaveMenu == null) { loadSaveMenu = GameObject.Find("Canvas").transform.Find("LoadSave Menu").gameObject; lsm = loadSaveMenu.GetComponent <LoadSaveMenu>(); } Highway highway = lsm.scene.highwayList.Find(item => item.id == highwayID); TThighwayID.text = highway.id; TThighwayType.text = highway.type.ToString("G"); TThighwayName.text = highway.name; IFhighwaySize.text = highway.waySize.ToString(); TGleftSidewalk.isOn = highway.hasLeftSidewalk; TGrightSidewalk.isOn = highway.hasRightSideWalk; IFleftSidewalkSize.text = highway.leftSidewalkSize.ToString(); IFrightSidewalkSize.text = highway.rightSidewalkSize.ToString(); fillLock = false; }
public string GetPrefix(PrefabAI ai, bool isOneWay, bool isSymmetric, float width, byte lanes, Randomizer rand, ushort segmentId, ushort seedId) { Highway highway = Highway.ANY; RoadType type = RoadType.NONE; if (ai is RoadBaseAI baseAi) { if (baseAi is DamAI) { type = RoadType.DAM; } else if (baseAi is RoadBridgeAI) { type = RoadType.BRIDGE; } else if (baseAi.IsUnderground()) { type = RoadType.TUNNEL; } else { type = RoadType.GROUND; } highway = baseAi.m_highwayRules ? Highway.TRUE : Highway.FALSE; } if (type == RoadType.NONE) { LogUtils.DoLog($"AI NAO IDENTIFICADA: {ai}"); return(null); } OneWay wayVal = isOneWay ? OneWay.TRUE : OneWay.FALSE; Symmetry symVal = isSymmetric ? Symmetry.TRUE : Symmetry.FALSE; LinkingType linking = LinkingType.NO_LINKING; SeedConfiguration seedConfiguration = (AdrNameSeedDataXml.Instance.NameSeedConfigs.TryGetValue(seedId, out AdrNameSeedConfig seedConf) && !(seedConf.HighwayParent is null) ? SeedConfiguration.HAS_HIGHWAY_TYPE : SeedConfiguration.NO_HIGHWAY_TYPE) | ((seedConf?.ForcedName).IsNullOrWhiteSpace()? SeedConfiguration.NO_FORCED_NAME : SeedConfiguration.HAS_FORCED_NAME); bool hasStart = true; bool hasEnd = true; if (wayVal == OneWay.TRUE && lanes <= 2) { SegmentUtils.GetSegmentRoadEdges(segmentId, true, true, true, out ComparableRoad startRef, out ComparableRoad endRef, out _); LogUtils.DoLog($"OneWay s={startRef}; e= {endRef}"); if (startRef.segmentReference == 0 || endRef.segmentReference == 0) { hasStart = startRef.segmentReference != 0; hasEnd = endRef.segmentReference != 0; } else if ((NetManager.instance.m_segments.m_buffer[startRef.segmentReference].Info.GetAI() is RoadBaseAI baseAiSource && baseAiSource.m_highwayRules) || (NetManager.instance.m_segments.m_buffer[endRef.segmentReference].Info.GetAI() is RoadBaseAI baseAiTarget && baseAiTarget.m_highwayRules)) { switch (startRef.CompareTo(endRef)) { case 1: linking = LinkingType.FROM_BIG; break; case 0: linking = LinkingType.SAME_SIZE; break; case -1: linking = LinkingType.FROM_SMALL; break; } } } List <RoadPrefixFileItem> filterResult = m_prefixes.Where(x => (x.roadType & type) == type && (x.oneWay & wayVal) == wayVal && (x.symmetry & symVal) == symVal && (x.highway & highway) == highway && (wayVal == OneWay.FALSE || ((x.linking & linking) == linking)) && (hasStart || !x.requireSource) && (hasEnd || !x.requireTarget) && x.minWidth <= width + 0.99f && width + 0.99f < x.maxWidth && x.minLanes <= lanes && lanes < x.maxLanes && (x.seedConfig & seedConfiguration) == seedConfiguration ).ToList(); if (filterResult.Count == 0 && linking != LinkingType.NO_LINKING) { filterResult = m_prefixes.Where(x => (x.roadType & type) == type && (x.oneWay & wayVal) == wayVal && (x.symmetry & symVal) == symVal && (x.highway & highway) == highway && (wayVal == OneWay.FALSE || ((x.linking & LinkingType.NO_LINKING) == LinkingType.NO_LINKING)) && (hasStart || !x.requireSource) && (hasEnd || !x.requireTarget) && x.minWidth <= width + 0.99f && width + 0.99f < x.maxWidth && x.minLanes <= lanes && lanes < x.maxLanes && (x.seedConfig & seedConfiguration) == seedConfiguration ).ToList(); } LogUtils.DoLog($"Results for: {type} O:{wayVal} S:{symVal} H:{highway} W:{width} L:{lanes} Lk:{linking} Hs:{hasStart} He:{hasEnd} Sc:{seedConfiguration} = {filterResult?.Count}"); if (filterResult?.Count == 0) { return(null); } return(filterResult[rand.Int32((uint)(filterResult.Count))].name); }
bool CeckForIntersection(Highway pieces, Highway[] movements) { for (int i = 0; i < movements.Length; i++) { if (pieces.x == movements[i].x && pieces.y == movements[i].y) return true; } return false; }
private void BuildButtonClick(UIComponent component, UIMouseEventParameter eventParam) { Debug.Log("Starting build"); // generate Airplane line, north / south Airline airline = new Airline(lat, lon); airline.Build(); foreach (Track track in airline.Tracks) { foreach (Node node in track.Nodes) { //BuildTool.instance.ActionQueue.Enqueue(node); } } Debug.Log("Airline generated"); Builds.Stream stream = new Builds.Stream(lat, lon); int unresolved = stream.Build(); Debug.Log($"OSM canals fetched, {stream.Tracks.Count} tracks, {unresolved} unresolved segments!"); foreach (Track track in stream.Tracks) { foreach (Node node in track.Nodes) { Vector3 pos = new Vector3(node.MapX, 0, node.MapY); node.TerrainHeight = TerrainManager.instance.SampleRawHeightSmooth(pos); BuildTool.instance.ActionQueue.Enqueue(node); } } Canal canal = new Canal(lat, lon); unresolved = canal.Build(); Debug.Log($"OSM canals fetched, {canal.Tracks.Count} tracks, {unresolved} unresolved segments!"); foreach (Track track in canal.Tracks) { foreach (Node node in track.Nodes) { Vector3 pos = new Vector3(node.MapX, 0, node.MapY); node.TerrainHeight = TerrainManager.instance.SampleRawHeightSmooth(pos); BuildTool.instance.ActionQueue.Enqueue(node); } } River river = new River(lat, lon); unresolved = river.Build(); Debug.Log($"OSM rivers fetched, {river.Tracks.Count} tracks, {unresolved} unresolved segments!"); foreach (Track track in river.Tracks) { foreach (Node node in track.Nodes) { Vector3 pos = new Vector3(node.MapX, 0, node.MapY); node.TerrainHeight = TerrainManager.instance.SampleRawHeightSmooth(pos); BuildTool.instance.ActionQueue.Enqueue(node); } } Highway highway = new Highway(lat, lon); unresolved = highway.Build(); Debug.Log($"OSM highways fetched, {highway.Tracks.Count} tracks, {unresolved} unresolved segments!"); foreach (Track track in highway.Tracks) { foreach (Node node in track.Nodes) { BuildTool.instance.ActionQueue.Enqueue(node); } } }
private void ParseWay(Way element) { if (!firstWay) { nids = milestones.Select(x => x.Id).ToList(); firstWay = true; } string taghighway; if (!element.Tags.TryGetValue("highway", out taghighway)) { return; } Highway tagHighwayEnum; if (!Highway.TryParse(taghighway, out tagHighwayEnum)) { if (!taghighway.Contains("_")) { return; } var split = taghighway.Split('_'); if (!(split.Length == 2 && split[1] == "link" && Highway.TryParse(split[0], out tagHighwayEnum))) { return; } } var intersect = Intersect(nids, element.Nodes.ToList()); if (intersect.Count == 0) { return; } WayRoute route; string tagref; element.Tags.TryGetValue("ref", out tagref); string tagname; element.Tags.TryGetValue("name", out tagname); string tagdescription; element.Tags.TryGetValue("description", out tagdescription); if (tagname != "" && tagname == tagdescription) { errors.Add(new RawError { Type = ErrorType.SameNameAndDescription, OsmType = OsmGeoType.Way, Id = (long)element.Id, Desc = tagname }); } route = new WayRoute { Id = (long)element.Id, Ref = tagref, Name = tagname, Description = tagdescription, Highway = tagHighwayEnum }; // привязование линии к точке foreach (var id in intersect) { var index = milestones.BinarySearch(new Milestone { Id = id }); var milestone = milestones[index]; if (milestone.WayRoute == null) { milestone.WayRoute = route; } else if (milestone.WayRoute.Highway < route.Highway) { milestone.WayRoute = route; } } }
void AddStepsToHighway(ref Highway piece, ref Highway[] array) { Array.Resize(ref array, array.Length + 1); array[array.Length - 1] = piece; }
private void LoadStreets() { RemoveStreets(); string strFilename = $"{Tool.StartupPath}\\streets_bw.sqlite"; RectLatLng bb = this.mcMapControl.ViewArea; //TODO: Check if the area is not to big ... But what is big ? SQLiteConnectionStringBuilder csbDatabase = new SQLiteConnectionStringBuilder { DataSource = strFilename }; using (SQLiteConnection dbConnection = new SQLiteConnection(csbDatabase.ConnectionString)) { dbConnection.Open(); try { // 0 1 2 3 //const string strSelectStatement = "select highway,ref,name,way from streets_bw where highway in ('motorway','motorway_link','trunk','trunk_link','primary','secondary','primary_link','secondary_link','residential')"; const string strSelectStatement = "select highway,ref,name,way from streets_bw"; uint iCounter = 0; DateTime dtStart = DateTime.Now; using (SQLiteCommand dbSelectCommand = new SQLiteCommand(strSelectStatement, dbConnection)) { using (SQLiteDataReader dbResult = dbSelectCommand.ExecuteReader()) { while (dbResult.Read()) { Highway type = Highway.Unknown; try { type = (Highway)Enum.Parse(typeof(Highway), dbResult.GetString(0), true); } catch (Exception ex) { Debug.WriteLine(ex.Message); } string strRef = dbResult.GetStringOrNull(1); string strName = dbResult.GetStringOrNull(2); LineString way = (LineString)dbResult.GetGeometryFromWKB(3); if (bb.Contains(way.Coordinate.ToPointLatLng())) { List <PointLatLng> list = new List <PointLatLng>(way.Count); list.AddRange(way.Coordinates.Select(pos => pos.ToPointLatLng())); this.Dispatcher.Invoke(() => { PathMarker mrWay = new PathMarker(this.mcMapControl, list, type, $"{( strName.IsNotEmpty() ? strName : "Unknown" )}{( strRef.IsNotEmpty() ? $" ({strRef})" : "" )}") { Tag = type }; this.mcMapControl.Markers.Add(mrWay); }); iCounter++; } } } } DateTime dtStop = DateTime.Now; MB.Information("Load {0} Ways In {1}.", iCounter, (dtStop - dtStart).ToHHMMSSString()); } catch (Exception ex) { MB.Error(ex); } finally { if (dbConnection.State == ConnectionState.Open) { dbConnection.Close(); } } } }
// Use this for initialization void Start() { oldPosition = transform.position; /// TEST FollowRoad infos = gameObject.GetComponent<FollowRoad>(); if (infos != null) { road = infos.road; oldRoadCenter = Highway.PointOnPath(road.nodes.ToArray(), infos.percentage); } }