// Token: 0x06001443 RID: 5187 RVA: 0x000212CC File Offset: 0x000202CC
        protected internal override void Execute(ActivityExecutionContext context)
        {
            Collection      trackLayoutDef  = base.Event.TrackLayoutDef;
            uint            num             = trackLayoutDef.Num_Checkpoints();
            uint            num2            = trackLayoutDef.Num_Shortcuts();
            int             laps            = base.Event.EventDef.NumLaps();
            TrackLayoutData trackLayoutData = new TrackLayoutData(num, num2, laps);
            Collection      collection      = new Collection(trackLayoutDef.StartGrid());

            trackLayoutData.AddPathPoint(0u, CoordSys.RenderToSim(collection.Position()), CoordSys.Vector3Make(collection.Rotation()));
            for (uint num3 = 0u; num3 < num; num3 += 1u)
            {
                Collection collection2 = new Collection(trackLayoutDef.Checkpoints(num3));
                trackLayoutData.AddPathPoint(num3 + 1u, CoordSys.RenderToSim(collection2.Position()), CoordSys.Vector3Make(collection2.Rotation()));
            }
            Collection collection3 = new Collection(trackLayoutDef.FinishLine());

            trackLayoutData.AddPathPoint(num + 1u, CoordSys.RenderToSim(collection3.Position()), CoordSys.Vector3Make(collection3.Rotation()));
            for (uint num4 = 0u; num4 < num2; num4 += 1u)
            {
                Collection collection4 = new Collection(trackLayoutDef.Shortcuts(num4));
                trackLayoutData.AddAlternatePoint(num4, CoordSys.RenderToSim(collection4.Position()), CoordSys.Vector3Make(collection4.Rotation()));
            }
            base.Event.TrackLayout.Resolve(trackLayoutData, false, -1, false);
        }
Пример #2
0
        void ActionMove(CoordSys coord)
        {
            var v = coord.WorldToLocal(rd.velocity);

            if (flying)
            {
                var deltaX = moveSpeed - v.x;
                v.x += deltaX * (1.0f - accRate);
            }
            else if (standingStable)
            {
                var deltaX = moveSpeed - v.x;
                deltaX = Mathf.Max(deltaX, 0.0f);
                v.x   += deltaX * (1.0f - accRate);
                v.y    = 0;
            }
            else
            {
                var res = 1.0f;
                for (int i = 0; i < contactCount; i++)
                {
                    if (recentContacts[i].collider != null)
                    {
                        if (coord.WorldToLocal(recentContacts[i].normal).Dot(Vector2.right).GEZ())
                        {
                            continue;
                        }
                        res = Mathf.Min(res, coord.WorldToLocal(recentContacts[i].normal).Dot(Vector2.left));
                    }
                }
                v.x = res * moveSpeed;
            }

            rd.velocity = coord.LocalToWorld(v);
        }
Пример #3
0
        /// <summary>
        /// Selects all of the features whose centroids lie within a given polygon.
        /// </summary>
        /// <remarks>This method searches for all features whose centroids are within the given polygon and updates the
        /// default selection.</remarks>
        /// <param name="mapAlias">MapAlias of the map.</param>
        /// <param name="points">Array of points forming the polygon.</param>
        public virtual void PolygonSelection(string mapAlias, System.Drawing.Point[] points)
        {
            Map map = GetMapObj(mapAlias);

            // Convert them to map coordinates
            MapInfo.Geometry.DPoint [] dpnts = new MapInfo.Geometry.DPoint[points.Length];
            for (int indx = 0; indx < points.Length; indx++)
            {
                map.DisplayTransform.FromDisplay(points[indx], out dpnts[indx]);
            }

            // Create a polygon from these points
            CoordSys dispCSys = map.GetDisplayCoordSys();
            CoordSys geomCSys =
                Session.Current.CoordSysFactory.CreateCoordSys(dispCSys.Type, dispCSys.Datum, dispCSys.Units, dispCSys.OriginLongitude, dispCSys.OriginLatitude, dispCSys.StandardParallelOne, dispCSys.StandardParallelTwo, dispCSys.Azimuth, dispCSys.ScaleFactor, dispCSys.FalseEasting, dispCSys.FalseNorthing, dispCSys.Range, map.Layers.Bounds, dispCSys.AffineTransform);

            MapInfo.Geometry.MultiPolygon mp = new MapInfo.Geometry.MultiPolygon(geomCSys, MapInfo.Geometry.CurveSegmentType.Linear, dpnts);

            // Search and select
            SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWithinGeometry(mp, ContainsType.Centroid);

            Session.Current.Selections.DefaultSelection.Clear();
            IMapLayerFilter _selFilter = MapLayerFilterFactory.FilterForTools(
                map, MapLayerFilterFactory.FilterByLayerType(LayerType.Normal), MapLayerFilterFactory.FilterVisibleLayers(true),
                "MapInfo.Tools.MapToolsDefault.SelectLayers", null);

            ITableEnumerator table = map.Layers.GetTableEnumerator(_selFilter);

            if (table != null)                 // null will be returned is select enabled layer is not visible, thus non-selectable
            {
                Session.Current.Catalog.Search(table, si, Session.Current.Selections.DefaultSelection, ResultSetCombineMode.AddTo);
            }
        }
Пример #4
0
        /// <summary>
        /// We are going to use the CoordSys transform to transform a point from one coordsys to another then back
        /// again to see if the round trip produces the correct results. Then test the array version of the transform.
        /// </summary>
        private void UseCoordinateTransform()
        {
            // create LongLat projection
            CoordSys csys = Session.Current.CoordSysFactory.CreateFromPrjString("1, 56");
            // Create Robinson projection
            CoordSys csys1 = Session.Current.CoordSysFactory.CreateFromPrjString("12, 62, 7, 0");

            if (csys == csys1)
            {
                outputTextBox.AppendText("Oops, coordsys's are equal, this is bad\n");
            }
            CoordinateTransform coordTransform = Session.Current.CoordSysFactory.CreateCoordinateTransform(csys, csys1);
            DPoint pntSrc       = new DPoint(0, 0);
            DPoint pntDest      = coordTransform.CoordSys1ToCoordSys2(pntSrc);
            DPoint pntSrc1      = new DPoint(1, 1);
            DPoint pntDest1     = coordTransform.CoordSys1ToCoordSys2(pntSrc1);
            DPoint pntBackToSrc = coordTransform.CoordSys2ToCoordSys1(pntDest1);

            ComparePoints("Round trip", pntSrc1, pntBackToSrc);
            // compare the result with arrays
            DPoint[] pnt = new DPoint[2];
            pnt[0].x = 0;
            pnt[0].y = 0;
            pnt[1].x = 1;
            pnt[1].y = 1;
            coordTransform.CoordSys1ToCoordSys2(pnt, out pnt);
            ComparePoints("Array converted", pntDest, pnt[0]);
            ComparePoints("Array converted", pntDest1, pnt[1]);
        }
Пример #5
0
 public override string GetSqlExpression()
 {
     return(string.Format(
                "MI_CentroidDistance(MI_Geometry, {0}, '{1}', 'Spherical') > {2} and "
                + "MI_CentroidDistance(MI_Geometry, {0}, '{3}', 'Spherical') < {4} ",
                paramName, CoordSys.DistanceUnitAbbreviation(_distanceInner.Unit), _distanceInner.Value,
                CoordSys.DistanceUnitAbbreviation(_distanceOuter.Unit), _distanceOuter.Value));
 }
        // Token: 0x060013A4 RID: 5028 RVA: 0x0001C80C File Offset: 0x0001B80C
        private void SetRespawnLocation()
        {
            Collection collection = new Collection(base.Event.EventDef.Checkpoints(this.checkpointIndex));

            this.Position.Value = CoordSys.RenderToSim(collection.Position());
            this.Rotation       = collection.Rotation();
            this.Mps.Value      = 0f;
        }
Пример #7
0
        // Token: 0x06001896 RID: 6294 RVA: 0x0002B828 File Offset: 0x0002A828
        public void Fill(RadarTracker tracker, Event evnt)
        {
            LocalHumanOpponent localHumanOpponent = Engine.Get().OpponentManager().FindLocalOpponent();
            double             num        = double.MaxValue;
            Collection         collection = null;

            for (uint num2 = 0u; num2 < evnt.EventDef.Num_Coins(); num2 += 1u)
            {
                Collection      collection2     = new Collection(evnt.EventDef.Coins(num2).GetCollectionKey());
                uint            collectionKey   = collection2.GetCollection();
                PointOfInterest pointOfInterest = evnt.PointsOfInterest.Find((PointOfInterest x) => x.Key == collectionKey);
                if (pointOfInterest != null && pointOfInterest.IsEnabled())
                {
                    double num3 = (double)GameCore.Math.Math.DistanceXZ2(localHumanOpponent.Vehicle.GetPosition(), CoordSys.RenderToSim(collection2.Position()));
                    if (num3 < num)
                    {
                        num        = num3;
                        collection = collection2;
                    }
                }
            }
            tracker.Enabled = false;
            tracker.SetMovieClipName("Treasure");
            if (collection != null)
            {
                GameCore.Math.Vector3 vector = CoordSys.RenderToSim(collection.Position());
                GameCore.Math.Vector3 p      = new GameCore.Math.Vector3(localHumanOpponent.Vehicle.GetPosition());
                GameCore.Math.Math.Sub(ref vector, p);
                double num4 = System.Math.Sqrt(GameCore.Math.Math.LengthSq(vector));
                if (num4 > (double)this.radarFarMax || num4 < (double)this.radarNearMin)
                {
                    tracker.Enabled  = false;
                    tracker.Distance = RadarDistance.kRadarDistance_OutOfRange;
                    return;
                }
                tracker.Enabled  = true;
                tracker.Distance = RadarDistance.kRadarDistance_Far;
                if (num4 < (double)this.radarMediumMin)
                {
                    tracker.Distance = RadarDistance.kRadarDistance_Near;
                }
                else if (num4 < (double)this.radarFarMin)
                {
                    tracker.Distance = RadarDistance.kRadarDistance_Medium;
                }
                UMath.Vector3         direction = localHumanOpponent.Vehicle.GetDirection();
                GameCore.Math.Vector2 p2        = new GameCore.Math.Vector2(direction.x, direction.z);
                GameCore.Math.Vector2 p3        = new GameCore.Math.Vector2(vector.x, vector.z);
                GameCore.Math.Math.Normalize(ref p3);
                float num5 = (float)System.Math.Acos((double)GameCore.Math.Math.Clamp <float>(GameCore.Math.Math.Dot(p2, p3), -1f, 1f));
                if (GameCore.Math.Math.Cross(p2, p3) < 0f)
                {
                    num5 = -num5;
                }
                tracker.DirectionDeg = Conversions.RAD2DEG(num5);
            }
        }
Пример #8
0
 // Token: 0x0600149E RID: 5278 RVA: 0x000226EC File Offset: 0x000216EC
 protected internal override void Execute(ActivityExecutionContext context)
 {
     for (uint num = 0u; num < base.Event.EventDef.Num_SpawnLocation(); num += 1u)
     {
         Collection collection = new Collection(base.Event.EventDef.SpawnLocation(num));
         Vector3    position   = CoordSys.RenderToSim(collection.Position());
         Vector3    direction  = CoordSys.Vector3Make(collection.Rotation());
         Cops.SpawnCop(collection.VehicleKey().GetKey(), position, direction);
     }
 }
        private void DrawFaceCoordinateSystem(CoordSys coordSys)
        {
            ColorSpacePoint pointNoseTip        = sensor.CoordinateMapper.MapCameraPointToColorSpace(coordSys.Front);
            ColorSpacePoint pointforeheadCenter = sensor.CoordinateMapper.MapCameraPointToColorSpace(coordSys.Top);
            ColorSpacePoint pointleftCheek      = sensor.CoordinateMapper.MapCameraPointToColorSpace(coordSys.Side);
            ColorSpacePoint pointavgPoint       = sensor.CoordinateMapper.MapCameraPointToColorSpace(coordSys.Center);

            DrawLine(pointforeheadCenter.X, pointforeheadCenter.Y, pointavgPoint.X, pointavgPoint.Y, 3, Colors.Blue);
            DrawLine(pointNoseTip.X, pointNoseTip.Y, pointavgPoint.X, pointavgPoint.Y, 3, Colors.Red);
            DrawLine(pointleftCheek.X, pointleftCheek.Y, pointavgPoint.X, pointavgPoint.Y, 3, Colors.Green);
        }
Пример #10
0
        private void FindCity()
        {
            Find find = null;

            try
            {
                MapInfo.Mapping.Map map = null;

                // Get the map
                if (MapInfo.Engine.Session.Current.MapFactory.Count == 0 ||
                    (map = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias]) == null)
                {
                    return;
                }

                // Do the find
                MapInfo.Mapping.FeatureLayer findLayer = (MapInfo.Mapping.FeatureLayer)map.Layers[_findLayerName];
                find = new Find(findLayer.Table, findLayer.Table.TableInfo.Columns[_findColumnName]);
                FindResult result = find.Search(DropDownList1.SelectedItem.Text);
                if (result.ExactMatch)
                {
                    // Create a Feature (point) for the location we found
                    CoordSys        csys = findLayer.CoordSys;
                    FeatureGeometry g    = new MapInfo.Geometry.Point(csys, result.FoundPoint.X, result.FoundPoint.Y);
                    Feature         f    = new Feature(g, new MapInfo.Styles.SimpleVectorPointStyle(52, System.Drawing.Color.DarkGreen, 32));

                    // Delete the existing find object and add the new one
                    MapInfo.Mapping.FeatureLayer workingLayer = (MapInfo.Mapping.FeatureLayer)map.Layers[_workingLayerName];
                    if (workingLayer != null)
                    {
                        (workingLayer.Table as ITableFeatureCollection).Clear();
                        workingLayer.Table.InsertFeature(f);
                    }

                    // Set the map's center and zooom
                    map.Center = new DPoint(result.FoundPoint.X, result.FoundPoint.Y);
                    MapInfo.Geometry.Distance d = new MapInfo.Geometry.Distance(1000, map.Zoom.Unit);
                    map.Zoom = d;
                }
                else
                {
                    this.Label3.Text = ("Cannot find the country");
                }
                find.Dispose();
            }
            catch (Exception)
            {
                if (find != null)
                {
                    find.Dispose();
                }
            }
        }
Пример #11
0
 /// <summary>
 /// 拷贝构造函数。
 /// </summary>
 /// <param name="coordSys">地图坐标系对象。</param>
 /// <exception cref="ArgumentException">当地图坐标系对象为 Null 时抛出异常。</exception>
 public CoordSys(CoordSys coordSys)
 {
     if (coordSys == null) throw new ArgumentException();
     if (coordSys.Datum != null)
         this.Datum = new Datum(coordSys.Datum);
     this.Name = Datum.Name;
     if (coordSys.PrimeMeridian != null)
         this.PrimeMeridian = new PrimeMeridian(coordSys.PrimeMeridian);
     this.SpatialRefType = coordSys.SpatialRefType;
     this.Type = coordSys.Type;
     this.Unit = coordSys.Unit;
 }
Пример #12
0
 // Token: 0x060014D6 RID: 5334 RVA: 0x00024EB4 File Offset: 0x00023EB4
 protected override void OnMessage(OnTriggerEnter message)
 {
     if (this.collection.GetCollection() == message.TriggerKey)
     {
         Opponent opponent = Engine.Get().OpponentManager().FindByPersonaId(message.PersonaId);
         if (opponent != null && opponent is LocalHumanOpponent)
         {
             Collection collection  = new Collection(this.collection);
             Collection collection2 = new Collection(collection.ResetMarker());
             opponent.Vehicle.WarpTo(CoordSys.RenderToSim(collection2.Position()), CoordSys.Vector3Make(collection2.Rotation()), 0f);
         }
     }
 }
Пример #13
0
        public static string ToString(CoordSys coordSys)
        {
            switch (coordSys)
            {
            case CoordSys.Polar:
                return("Polar");

            case CoordSys.Cartesian:
                return("Cartesian");

            default:
                throw new ArgumentOutOfRangeException(nameof(coordSys), coordSys, null);
            }
        }
        // Token: 0x060013D3 RID: 5075 RVA: 0x0001CF54 File Offset: 0x0001BF54
        protected internal override void Execute(ActivityExecutionContext context)
        {
            uint num = base.Event.EventDef.Num_RespawnLocation();

            if (num > 0u)
            {
                uint       index      = (uint)(base.Entrant.Opponent.GridIndex % (int)num);
                Collection collection = new Collection(base.Event.EventDef.RespawnLocation(index));
                this.Position.Value = CoordSys.RenderToSim(collection.Position());
                this.Rotation       = collection.Rotation();
                this.Mps.Value      = 0f;
            }
            this.Close();
        }
Пример #15
0
        /// <summary>
        /// 初始化地图数据到内存
        /// </summary>
        public void InitMemMap()
        {
            mControl = new MapControl();
            string path      = Application.StartupPath; //Assembly.GetExecutingAssembly().Location;
            String TablePath = Path.Combine(path, "Map");
            String MWSPath   = Path.Combine(TablePath, "map.mws");

            MapInfo.Mapping.MapTableLoader tLoader = new MapTableLoader();
            map = mControl.Map;
            MapWorkSpaceLoader mwsLoader = new MapWorkSpaceLoader(MWSPath);

            map.Load(mwsLoader);
            cs = map.GetDisplayCoordSys();
        }
Пример #16
0
 // Token: 0x060019CD RID: 6605 RVA: 0x0002F15C File Offset: 0x0002E15C
 public void Execute(Event evnt, EntrantInfo entrant, Collection trigger)
 {
     if (trigger.Num_Marker() < 1u)
     {
         return;
     }
     for (uint num = 0u; num < trigger.Num_Marker(); num += 1u)
     {
         Collection collection = new Collection(trigger.Marker(num));
         if (!collection.IsDerivedFrom(289837591u))
         {
             return;
         }
         Traffic.SpawnTraffic(collection.VehicleKey().GetKey(), CoordSys.RenderToSim(collection.Position()), CoordSys.Vector3Make(collection.Rotation()), collection.InitialSpeed());
     }
 }
Пример #17
0
 // Token: 0x06001473 RID: 5235 RVA: 0x00021D6C File Offset: 0x00020D6C
 private void BuildWarpList()
 {
     foreach (EntrantInfo entrantInfo in base.Event.Entrants)
     {
         WarpTo warpTo = new WarpTo();
         uint   num    = base.Event.TrackLayoutDef.Num_SpawnLocation();
         if (num > 0u)
         {
             uint       index      = (uint)(entrantInfo.Opponent.GridIndex % (int)num);
             Collection collection = new Collection(base.Event.TrackLayoutDef.SpawnLocation(index));
             warpTo.Position  = CoordSys.RenderToSim(collection.Position());
             warpTo.Direction = CoordSys.Vector3Make(collection.Rotation());
             warpTo.Vehicle   = entrantInfo.Opponent.Vehicle;
             this.warpList.Add(warpTo);
         }
     }
 }
Пример #18
0
 // Token: 0x060019CA RID: 6602 RVA: 0x0002F0B0 File Offset: 0x0002E0B0
 public void Execute(Event evnt, EntrantInfo entrant, Collection trigger)
 {
     if (trigger.Num_Marker() < 1u)
     {
         return;
     }
     for (uint num = 0u; num < trigger.Num_Marker(); num += 1u)
     {
         Collection collection = new Collection(trigger.Marker(num));
         if (!collection.IsDerivedFrom(1001100515u))
         {
             return;
         }
         KeyList keyList = new KeyList(collection.Num_Vehicles());
         for (uint num2 = 0u; num2 < collection.Num_Vehicles(); num2 += 1u)
         {
             keyList.AddKey(collection.Vehicles(num2).GetKey());
         }
         Cops.CreateRoadblock(CoordSys.RenderToSim(collection.Position()), CoordSys.Vector3Make(collection.Rotation()), keyList, collection.ShouldUseSpikeStrips(), collection.MinLifetime());
     }
 }
Пример #19
0
        // Token: 0x060012CB RID: 4811 RVA: 0x0001AED4 File Offset: 0x00019ED4
        protected internal override void Execute(ActivityExecutionContext context)
        {
            Collection collection = new Collection(this.EventKey.Value);

            if (!collection.IsValid())
            {
                return;
            }
            Collection collection2 = new Collection(collection.TrackLayout());

            if (!collection2.IsValid())
            {
                return;
            }
            Vector3    render      = new Vector3();
            float      rotation    = 0f;
            Collection collection3 = new Collection(collection2.StartGrid());

            if (collection3.IsValid())
            {
                render   = collection3.Position();
                rotation = collection3.Rotation();
            }
            else
            {
                uint num = collection2.Num_SpawnLocation();
                if (num > 0u)
                {
                    Collection collection4 = new Collection(collection2.SpawnLocation(0u));
                    render   = collection4.Position();
                    rotation = collection4.Rotation();
                }
            }
            Opponent opponent = Engine.Get().OpponentManager().FindLocalOpponent();

            if (opponent != null)
            {
                opponent.InternalOpponent.TeleportTo(CoordSys.RenderToSim(render), CoordSys.Vector3Make(rotation));
            }
        }
    void Update()
    {
        if (active)
        {
            var curPos    = (Vector2)(this.transform.position - offset);
            var targetPos = (Vector2)target.transform.position;

            var relativePos      = curPos.To(targetPos);
            var localCoord       = new CoordSys(Vector2.right * cam.orthographicSize * cam.aspect, Vector2.up * cam.orthographicSize);
            var localRelativePos = localCoord.WorldToLocal(relativePos);
            localP             = localRelativePos;
            localRelativePos.x = localRelativePos.x.Clamp(-limitRatio, limitRatio);
            localRelativePos.y = localRelativePos.y.Clamp(-limitRatio, limitRatio);
            var clampedRelativePos = localCoord.LocalToWorld(localRelativePos);

            var lb = localCoord.WorldToLocal(curPos) + Vector2.left * limitRatio + Vector2.down * limitRatio;
            var rb = localCoord.WorldToLocal(curPos) + Vector2.right * limitRatio + Vector2.down * limitRatio;
            var lt = localCoord.WorldToLocal(curPos) + Vector2.left * limitRatio + Vector2.up * limitRatio;
            var rt = localCoord.WorldToLocal(curPos) + Vector2.right * limitRatio + Vector2.up * limitRatio;
            lb = localCoord.LocalToWorld(lb);
            rb = localCoord.LocalToWorld(rb);
            lt = localCoord.LocalToWorld(lt);
            rt = localCoord.LocalToWorld(rt);
            Debug.DrawLine(lb, rb, Color.red);
            Debug.DrawLine(lt, rt, Color.red);
            Debug.DrawLine(lb, lt, Color.red);
            Debug.DrawLine(rb, rt, Color.red);

            var clampedPos = (Vector2)targetPos - clampedRelativePos;

            this.transform.position = (Vector3)clampedPos + offset;

            var targetMove = (Vector2)targetPos - clampedPos;
            var moveDist   = targetMove.magnitude * closeRatePerFrame;
            moveDist.UpdMax(minSpeed * Time.deltaTime);
            moveDist.UpdMin(targetMove.magnitude);

            this.transform.position = offset + (Vector3)(clampedPos + targetMove.normalized * moveDist);
        }
    }
Пример #21
0
    // coord: default is right: +x axis, up : +y axis.
    //        if you want to use left: +x axis simply reverse it in CoordSys constructor.
    void ActionMove(CoordSys movingCoord)
    {
        Vector2 DirectionalReduceVelocity(Vector2 vs)
        {
            foreach (var c in contactDetector.recentContacts)
            {
                if (c.collider != null)
                {
                    if (movingCoord.WorldToLocal(c.normal).Dot(Vector2.right).GEZ())
                    {
                        continue;
                    }
                    var groundCoord = new CoordSys(c.normal, c.normal.RotHalfPi());
                    vs = groundCoord.LocalToWorld(groundCoord.WorldToLocal(vs).Y(0));
                }
            }
            return(vs);
        }

        var v = movingCoord.WorldToLocal(rd.velocity);

        if (flying)
        {
            v.x = moveSpeed.Min(0f.Max(v.x) + accPerPhysicsFrame);
            DirectionalReduceVelocity(v);
        }
        else if (standingStable)
        {
            v.x = moveSpeed.Min(0f.Max(v.x) + accPerPhysicsFrame);
            DirectionalReduceVelocity(v);
            v.y = 0f.Max(v.y);
        }
        else
        {
            // v = Vector2.right * moveSpeed * 0.5f;
            DirectionalReduceVelocity(v);
        }

        rd.velocity = movingCoord.LocalToWorld(v);
    }
Пример #22
0
 // The method called when the user chooses the Choose Coordinate System menuitem
 private void MenuItemChooseCoordSys(Object sender, System.EventArgs e)
 {
     if (mapControl1.Map.IsDisplayCoordSysReadOnly)
     {
         // We cannot allow the user to change the coordinate system if
         // the coordinate system is locked due to a raster layer.
         MessageBox.Show("Coordinate system is currently restricted, due to a raster layer.");
     }
     else
     {
         CoordSysPickerDlg csysDlg = new CoordSysPickerDlg();
         csysDlg.SelectedCoordSys = mapControl1.Map.GetDisplayCoordSys();
         if (csysDlg.ShowDialog(this) == DialogResult.OK)
         {
             CoordSys csysNew = csysDlg.SelectedCoordSys;
             if (csysNew != mapControl1.Map.GetDisplayCoordSys())
             {
                 mapControl1.Map.SetDisplayCoordSys(csysNew);
             }
         }
     }
 }
Пример #23
0
 public static string ToString(CoordSys coordSys)
 {
     switch (coordSys)
     {
         case CoordSys.Polar:
             return "Polar";
         case CoordSys.Cartesian:
             return "Cartesian";
         default:
             throw new ArgumentOutOfRangeException(nameof(coordSys), coordSys, null);
     }
 }
Пример #24
0
        private static void PoliceData()
        {
            string connStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Jose\Dropbox\dev\net\2010\Truenorth\Compass\Solution Files\Data\SampleMDB.mdb;Persist Security Info=False";

            using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.CompassDbConnString))
                using (OleDbConnection oleConn = new OleDbConnection(connStr))
                {
                    conn.Open();
                    oleConn.Open();


                    using (SqlCommand cmd = new SqlCommand())
                        using (OleDbCommand oleCmd = new OleDbCommand())
                        {
                            cmd.Connection  = conn;
                            cmd.CommandText =
                                "INSERT INTO [dbo].[Location] ([LocationTypeEnumCode]," + "\r\n" +
                                "                              [LocationGroupEnumCode]," + "\r\n" +
                                "                              [SourceIntUniqueKey]," + "\r\n" +
                                "                              [Name]," + "\r\n" +
                                "                              [DescriptionEn]," + "\r\n" +
                                "                              [DescriptionEs]," + "\r\n" +
                                "                              [Address1]," + "\r\n" +
                                "                              [Address2]," + "\r\n" +
                                "                              [City]," + "\r\n" +
                                "                              [State]," + "\r\n" +
                                "                              [ZipCode]," + "\r\n" +
                                "                              [Latitude]," + "\r\n" +
                                "                              [Longitude]," + "\r\n" +
                                "                              [IncidentDate])" + "\r\n" +
                                "VALUES (1," + "\r\n" +
                                "        6," + "\r\n" +
                                "        @SourceIntUniqueKey," + "\r\n" +
                                "        @Name," + "\r\n" +
                                "        @DescriptionEn," + "\r\n" +
                                "        @DescriptionEs," + "\r\n" +
                                "        @Address1," + "\r\n" +
                                "        @Address2," + "\r\n" +
                                "        @City," + "\r\n" +
                                "        @State," + "\r\n" +
                                "        @ZipCode," + "\r\n" +
                                "        @Latitude," + "\r\n" +
                                "        @Longitude," + "\r\n" +
                                "        @IncidentDate);";

                            SqlParameter sourceIntUniqueKeyParam = cmd.Parameters.Add("@SourceIntUniqueKey", System.Data.SqlDbType.Int);
                            SqlParameter nameParam          = cmd.Parameters.Add("@Name", System.Data.SqlDbType.VarChar, 30);
                            SqlParameter descriptionEnParam = cmd.Parameters.Add("@DescriptionEn", System.Data.SqlDbType.VarChar, 50);
                            SqlParameter descriptionEsParam = cmd.Parameters.Add("@DescriptionEs", System.Data.SqlDbType.VarChar, 50);
                            SqlParameter address1Param      = cmd.Parameters.Add("@Address1", System.Data.SqlDbType.VarChar, 50);
                            SqlParameter address2Param      = cmd.Parameters.Add("@Address2", System.Data.SqlDbType.VarChar, 50);
                            SqlParameter cityParam          = cmd.Parameters.Add("@City", System.Data.SqlDbType.VarChar, 30);
                            SqlParameter stateParam         = cmd.Parameters.Add("@State", System.Data.SqlDbType.VarChar, 30);
                            SqlParameter zipCodeParam       = cmd.Parameters.Add("@ZipCode", System.Data.SqlDbType.VarChar, 10);
                            SqlParameter latitudeParam      = cmd.Parameters.Add("@Latitude", System.Data.SqlDbType.Float);
                            SqlParameter longitudeParam     = cmd.Parameters.Add("@Longitude", System.Data.SqlDbType.Float);
                            SqlParameter incidentDateParam  = cmd.Parameters.Add("@IncidentDate", System.Data.SqlDbType.DateTime);

                            stateParam.Value    = "PR";
                            address1Param.Value = string.Empty;
                            address2Param.Value = string.Empty;
                            cityParam.Value     = string.Empty;
                            zipCodeParam.Value  = string.Empty;

                            oleCmd.Connection  = oleConn;
                            oleCmd.CommandText =
                                "SELECT incidencia2013sample.[OBJECTID]," + "\r\n" +
                                "       incidencia2013sample.[fecha_ocurrencia]," + "\r\n" +
                                "       incidencia2013sample.[hora_ocurrencia]," + "\r\n" +
                                "       incidencia2013sample.[FK_delito_cometido_Tipo_I]," + "\r\n" +
                                "       incidencia2013sample.[POINT_X]," + "\r\n" +
                                "       incidencia2013sample.[POINT_Y]" + "\r\n" +
                                "  FROM incidencia2013sample;";

                            CoordSys A = CoordSys.GetCS("US_SPC83", "PRVI83", "PUERTO RICO", "METERS");
                            CoordSys B = CoordSys.GetCS("LAT_LONG", "LAT-LONG", "PUERTO RICO", "METERS");

                            double[] LonX = new double[1];
                            double[] LatY = new double[1];
                            double[] Z    = new double[1];

                            Z[0] = 0.0;

                            using (OleDbDataReader oleReader = oleCmd.ExecuteReader())
                            {
                                while (oleReader.Read())
                                {
                                    if (!oleReader.IsDBNull(0) && !oleReader.IsDBNull(1) && !oleReader.IsDBNull(2) && !oleReader.IsDBNull(3) && !oleReader.IsDBNull(4) && !oleReader.IsDBNull(5))
                                    {
                                        int      objId                  = oleReader.GetInt32(0);
                                        DateTime fecha_ocurrencia       = oleReader.GetDateTime(1);
                                        string   hora_ocurrencia        = oleReader.GetString(2).EnsureNotNull(true);
                                        int      delito_cometido_Tipo_I = oleReader.GetInt32(3);
                                        double   x = oleReader.GetDouble(4);
                                        double   y = oleReader.GetDouble(5);

                                        DateTime hour;

                                        if (DateTime.TryParse(hora_ocurrencia, out hour))
                                        {
                                            fecha_ocurrencia = new DateTime(fecha_ocurrencia.Year, fecha_ocurrencia.Month, fecha_ocurrencia.Day, hour.Hour, hour.Minute, hour.Second);
                                        }

                                        int    proveedorId = objId;
                                        string nombre      = "Delito Tipo I - " + delito_cometido_Tipo_I.ToString();

                                        string estAuthNumber = delito_cometido_Tipo_I.ToString();

                                        LonX[0] = DMS.GetLon(x.ToString());
                                        LatY[0] = DMS.GetLat(y.ToString());

                                        CoordSys.Transform(A, B, LonX, LatY, Z, 1);

                                        double longitud = Math.Round(LonX[0], 9);
                                        double latitud  = Math.Round(LatY[0], 9);

                                        sourceIntUniqueKeyParam.Value = proveedorId;
                                        nameParam.Value          = nombre;
                                        descriptionEnParam.Value = estAuthNumber;
                                        descriptionEsParam.Value = estAuthNumber;

                                        latitudeParam.Value  = latitud;
                                        longitudeParam.Value = longitud;

                                        incidentDateParam.Value = fecha_ocurrencia;

                                        cmd.ExecuteNonQuery();
                                    }
                                }
                            }
                        }
                }
        }
Пример #25
0
        // Token: 0x06001743 RID: 5955 RVA: 0x000296E8 File Offset: 0x000286E8
        internal float GetDistanceToStartLine(Vehicle vehicle)
        {
            Collection collection = new Collection(this.TrackLayoutDef.StartGrid());

            return(GameCore.Math.Math.DistanceXZ2(CoordSys.RenderToSim(collection.Position()), vehicle.GetPosition()));
        }