Ejemplo n.º 1
0
        public void Test()
        {
            //Create source spatial reference.

            Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");

            System.Object obj = Activator.CreateInstance(factoryType);

            ISpatialReferenceFactory3 spatialReferenceFactory = obj as ISpatialReferenceFactory3;



            ISpatialReference spatialReference = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)

                                                                                                          esriSRGeoCSType.esriSRGeoCS_WGS1984);

            spatialReference.SetFalseOriginAndUnits(-80.0000000232831, 39.9999999767169, 42949672.9);

            //Create an envelope and define its spatial reference.

            IEnvelope envelope = new EnvelopeClass();

            envelope.PutCoords(-68.6076204314651, 49.6186709634653, -68.5531907607304, 49.6530789785679);

            envelope.SpatialReference = spatialReference;

            //Destination spatial reference.

            ISpatialReference projectedCoordinateSystem = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)

                                                                                                                  esriSRProjCSType.esriSRProjCS_NAD1927UTM_19N);

            //Define the XYDomain equivalent to SetFalseOriginAndUnits.

            projectedCoordinateSystem.SetDomain(500000, 600000, 5300000, 5600000);

            String report = "Print envelope coordinates before projection:\n" +

                            envelope.XMin + " , " + envelope.YMin + " , " + envelope.XMax + " , " +

                            envelope.YMax + "\n\n\n";

            //Project envelope.

            IGeometry geometry = envelope as IGeometry2;

            geometry.Project(projectedCoordinateSystem as ISpatialReference);

            report = report + "Print envelope coordinates after projection:\n" +

                     envelope.XMin + " , " + envelope.YMin + " , " + envelope.XMax + " , " +

                     envelope.YMax;

            System.Windows.Forms.MessageBox.Show(report);
        }
Ejemplo n.º 2
0
        /// <summary> Class to handle a boundingbox, that make sure it is within Flanderers
        /// and return string string in the wanted format from arcgis IEnvelope </summary>
        /// <param name="arcgisBbox">arcgis IEnvelope </param>
        public boundingBox(IEnvelope arcgisBbox)
        {
            //handle SRS
            inSRS = arcgisBbox.SpatialReference;

            //Set maxbounds
            Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");

            System.Object             obj = Activator.CreateInstance(factoryType);
            ISpatialReferenceFactory3 spatialReferenceFactory = obj as ISpatialReferenceFactory3;

            ISpatialReference lam72     = spatialReferenceFactory.CreateSpatialReference(31370);
            IEnvelope         maxBounds = geopuntHelper.makeExtend(17750, 23720, 297240, 245340, lam72); //not outside flanders

            if (inSRS.FactoryCode != lam72.FactoryCode)
            {
                maxBounds = geopuntHelper.Transform(maxBounds as IGeometry, inSRS) as IEnvelope;
            }
            if (arcgisBbox.XMin > maxBounds.XMin)
            {
                Xmin = arcgisBbox.XMin;
            }
            else
            {
                Xmin = maxBounds.XMin;
            }
            if (arcgisBbox.YMin > maxBounds.YMin)
            {
                Ymin = arcgisBbox.YMin;
            }
            else
            {
                Ymin = maxBounds.YMin;
            }
            if (arcgisBbox.XMax < maxBounds.XMax)
            {
                Xmax = arcgisBbox.XMax;
            }
            else
            {
                Xmax = maxBounds.XMax;
            }
            if (arcgisBbox.YMax < maxBounds.YMax)
            {
                Ymax = arcgisBbox.YMax;
            }
            else
            {
                Ymax = maxBounds.YMax;
            }
        }
Ejemplo n.º 3
0
        public WindowsLocationManager()
        {
            _map        = _mxDocument.FocusMap;
            _srFactory  = new SpatialReferenceEnvironment() as ISpatialReferenceFactory3;
            _EPSG_MAPPA = _map.SpatialReference.FactoryCode;
            _SR_WGS84   = (ISpatialReference3)_srFactory.CreateSpatialReference(_EPSG_WGS84);
            _SRMappa    = (ISpatialReference3)_srFactory.CreateSpatialReference(_EPSG_MAPPA);
            GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();

            watcher.PositionChanged += Watcher_PositionChanged;
            bool bStarted = watcher.TryStart(false, TimeSpan.FromMilliseconds(2000));

            if (!bStarted)
            {
                MessageBox.Show("GeoCoordinateWatcher timed out all'avvio", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Gets the linear unit from the esri constants for linear units
        /// </summary>
        /// <returns>ILinearUnit</returns>
        internal ILinearUnit GetLinearUnit()
        {
            int unitType = (int)esriSRUnitType.esriSRUnit_Meter;

            if (srf3 == null)
            {
                Type srType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
                srf3 = Activator.CreateInstance(srType) as ISpatialReferenceFactory3;
            }

            switch (LineDistanceType)
            {
            case DistanceTypes.Feet:
                unitType = (int)esriSRUnitType.esriSRUnit_Foot;
                break;

            case DistanceTypes.Kilometers:
                unitType = (int)esriSRUnitType.esriSRUnit_Kilometer;
                break;

            case DistanceTypes.Meters:
                unitType = (int)esriSRUnitType.esriSRUnit_Meter;
                break;

            case DistanceTypes.NauticalMile:
                unitType = (int)esriSRUnitType.esriSRUnit_NauticalMile;
                break;

            case DistanceTypes.SurveyFoot:
                unitType = (int)esriSRUnitType.esriSRUnit_SurveyFoot;
                break;

            default:
                unitType = (int)esriSRUnitType.esriSRUnit_Meter;
                break;
            }

            return(srf3.CreateUnit(unitType) as ILinearUnit);
        }
Ejemplo n.º 5
0
        public batchGeocodeForm( )
        {
            //set global objects
            view = ArcMap.Document.ActiveView;
            map = view.FocusMap;

            Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
            System.Object obj = Activator.CreateInstance(factoryType);
            spatialReferenceFactory = obj as ISpatialReferenceFactory3;

            lam72 = spatialReferenceFactory.CreateProjectedCoordinateSystem(31370);

            gpExtension = geopunt4arcgisExtension.getGeopuntExtension();

            loc = new dataHandler.adresLocation( timeout: gpExtension.timeout);
            sug = new dataHandler.adresSuggestion( timeout: gpExtension.timeout);

            graphics = new List<IElement>();

            InitializeComponent();

            initGui();
        }
Ejemplo n.º 6
0
        public batchGeocodeForm( )
        {
            //set global objects
            view = ArcMap.Document.ActiveView;
            map  = view.FocusMap;

            Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");

            System.Object obj = Activator.CreateInstance(factoryType);
            spatialReferenceFactory = obj as ISpatialReferenceFactory3;

            lam72 = spatialReferenceFactory.CreateProjectedCoordinateSystem(31370);

            gpExtension = geopunt4arcgisExtension.getGeopuntExtension();

            loc = new dataHandler.adresLocation(timeout: gpExtension.timeout);
            sug = new dataHandler.adresSuggestion(timeout: gpExtension.timeout);

            graphics = new List <IElement>();

            InitializeComponent();

            initGui();
        }
        /// <summary>
        /// Gets the linear unit from the esri constants for linear units
        /// </summary>
        /// <returns>ILinearUnit</returns>
        internal ILinearUnit GetLinearUnit()
        {
            int unitType = (int)esriSRUnitType.esriSRUnit_Meter;
             if (srf3 == null)
            {
                Type srType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
                srf3 = Activator.CreateInstance(srType) as ISpatialReferenceFactory3;
            }

            switch (LineDistanceType)
            {
                case DistanceTypes.Feet:
                    unitType = (int)esriSRUnitType.esriSRUnit_Foot;
                    break;
                case DistanceTypes.Kilometers:
                    unitType = (int)esriSRUnitType.esriSRUnit_Kilometer;
                    break;
                case DistanceTypes.Meters:
                    unitType = (int)esriSRUnitType.esriSRUnit_Meter;
                    break;
                case DistanceTypes.NauticalMile:
                    unitType = (int)esriSRUnitType.esriSRUnit_NauticalMile;
                    break;
                case DistanceTypes.SurveyFoot:
                    unitType = (int)esriSRUnitType.esriSRUnit_SurveyFoot;
                    break;
                default:
                    unitType = (int)esriSRUnitType.esriSRUnit_Meter;
                    break;
            }

            return srf3.CreateUnit(unitType) as ILinearUnit;
        }