Ejemplo n.º 1
0
 private FeatureDataRow GetRow(double p1, double p2)
 {
     pointFeature          = pointTable.NewRow();
     pointFeature["Label"] = location.ToString();
     pointFeature.Geometry = new NetTopologySuite.Geometries.Point(p1, p2);
     return(pointFeature);
 }
Ejemplo n.º 2
0
        public bool SetLocation(FactLocation loc, int level)
        {
            while (!loaded)
            {
                Application.DoEvents();
            }
            GeoResponse.CResult.CGeometry.CViewPort viewport = null;
            GeoResponse res = null;

            Object[] args = new Object[] { 0, 0 };
            if (loc.IsGeoCoded(false) && loc.ViewPort != null)
            {
                labMapLevel.Text = "Previously Geocoded: " + loc.ToString();
                viewport         = MapTransforms.ReverseTransformViewport(loc.ViewPort);
                args             = new Object[] { loc.Latitude, loc.Longitude };
            }
            else
            {
                location = loc.ToString();
                res      = CallGoogleGeocode(location);
                if (res.Status == "OK")
                {
                    labMapLevel.Text = GoogleMap.LocationText(res, loc, level);
                    viewport         = res.Results[0].Geometry.ViewPort;
                    double lat = res.Results[0].Geometry.Location.Lat;
                    double lng = res.Results[0].Geometry.Location.Long;
                    args = new Object[] { lat, lng };
                }
                else if (res.Status == "OVER_QUERY_LIMIT" && loc.IsGeoCoded(false))
                {
                    labMapLevel.Text        = "Previously Geocoded: " + loc.ToString();
                    viewport                = new GeoResponse.CResult.CGeometry.CViewPort();
                    viewport.NorthEast.Lat  = loc.Latitude + 2;
                    viewport.NorthEast.Long = loc.Longitude + 2;
                    viewport.SouthWest.Lat  = loc.Latitude - 2;
                    viewport.SouthWest.Long = loc.Longitude - 2;
                    args = new Object[] { loc.Latitude, loc.Longitude };
                }
                else
                {
                    return(false);
                }
            }
            Object marker = webBrowser.Document.InvokeScript("frontAndCenter", args);

            args = new Object[] { viewport.NorthEast.Lat, viewport.NorthEast.Long, viewport.SouthWest.Lat, viewport.SouthWest.Long };
            webBrowser.Document.InvokeScript("setViewport", args);
            webBrowser.Show();
            return(true);
        }
Ejemplo n.º 3
0
        public void SetLocation(FactLocation loc, int level)
        {
            this.Text = "Individuals & Families with connection to " + loc.ToString();
            level     = Math.Min(loc.Level, level); // if location level isn't as detailed as level on tab use location level
            IEnumerable <Individual> listInd = ft.GetIndividualsAtLocation(loc, level);
            SortableBindingList <IDisplayIndividual> dsInd = new SortableBindingList <IDisplayIndividual>();

            foreach (Individual i in listInd)
            {
                dsInd.Add(i);
            }
            dgIndividuals.DataSource = dsInd;
            SortIndividuals();

            IEnumerable <Family> listFam = ft.GetFamiliesAtLocation(loc, level);
            SortableBindingList <IDisplayFamily> dsFam = new SortableBindingList <IDisplayFamily>();

            foreach (Family f in listFam)
            {
                dsFam.Add(f);
            }
            dgFamilies.DataSource = dsFam;
            SortFamilies();
            splitContainer.Panel2Collapsed = false;
            UpdateStatusCount();
        }
Ejemplo n.º 4
0
 public bool SetLocation(FactLocation loc, int level)
 {
     if (loc is null)
     {
         return(false);
     }
     while (!loaded)
     {
         Application.DoEvents();
     }
     GeoResponse.CResult.CGeometry.CViewPort viewport;
     if (loc.IsGeoCoded(false) && loc.ViewPort != null)
     {
         labMapLevel.Text = "Previously Geocoded: " + loc.ToString();
         viewport         = MapTransforms.ReverseTransformViewport(loc.ViewPort);
     }
     else
     {
         GeoResponse res = GoogleMap.CallGoogleGeocode(loc, loc.ToString());
         if (res.Status == "OK")
         {
             labMapLevel.Text = GoogleMap.LocationText(res, loc, level);
             viewport         = res.Results[0].Geometry.ViewPort;
         }
         else if (res.Status == "OVER_QUERY_LIMIT" && loc.IsGeoCoded(false))
         {
             labMapLevel.Text        = "Previously Geocoded: " + loc.ToString();
             viewport                = new GeoResponse.CResult.CGeometry.CViewPort();
             viewport.NorthEast.Lat  = loc.Latitude + 2;
             viewport.NorthEast.Long = loc.Longitude + 2;
             viewport.SouthWest.Lat  = loc.Latitude + 2;
             viewport.SouthWest.Long = loc.Longitude + 2;
         }
         else
         {
             return(false);
         }
     }
     object[] args = new object[] { viewport.NorthEast.Lat, viewport.NorthEast.Long, viewport.SouthWest.Lat, viewport.SouthWest.Long };
     webBrowser.Document.InvokeScript("setBounds", args);
     webBrowser.Show();
     return(true);
 }
Ejemplo n.º 5
0
 public void ShowLocation(FactLocation loc, int level)
 {
     if (loc.IsGeoCoded(false))
     {
         string URL = $"https://www.google.com/maps/@{loc.Latitude},{loc.Longitude},{level}z";
         SpecialMethods.VisitWebsite(URL);
     }
     else
     {
         MessageBox.Show($"{loc.ToString()} is not yet geocoded so can't be displayed.");
     }
 }
Ejemplo n.º 6
0
 public static void GetLocationDetails(FactLocation location)
 {
     if (location.ToString().Length == 0)
     {
         return;
     }
     if (InstanceConnection.State != ConnectionState.Open)
     {
         InstanceConnection.Open();
     }
     ReadLocationIntoFact(location, InstanceConnection);
 }
Ejemplo n.º 7
0
 public void GetLocationDetails(FactLocation location)
 {
     if (location.ToString().Length == 0)
     {
         return;
     }
     using (SQLiteConnection conn = new SQLiteConnection(connectionString))
     {
         conn.Open();
         ReadLocationIntoFact(location, conn);
     }
 }
Ejemplo n.º 8
0
 static void ReadLocationIntoFact(FactLocation location, SQLiteConnection conn)
 {
     using (SQLiteCommand cmd = new SQLiteCommand("select latitude, longitude, latm, longm, viewport_x_ne, viewport_y_ne, viewport_x_sw, viewport_y_sw, geocodestatus, foundlevel, foundlocation, foundresulttype from geocode where location = ?", conn))
     {
         SQLiteParameter param = cmd.CreateParameter();
         param.DbType = DbType.String;
         cmd.Parameters.Add(param);
         cmd.Prepare();
         cmd.Parameters[0].Value = location.ToString();
         using (SQLiteDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
         {
             if (reader.Read())
             {
                 double.TryParse(reader["latitude"].ToString(), out double latitude);
                 double.TryParse(reader["longitude"].ToString(), out double longitude);
                 double.TryParse(reader["latm"].ToString(), out double latm);
                 double.TryParse(reader["longm"].ToString(), out double longm);
                 double.TryParse(reader["viewport_x_ne"].ToString(), out double viewport_x_ne);
                 double.TryParse(reader["viewport_y_ne"].ToString(), out double viewport_y_ne);
                 double.TryParse(reader["viewport_x_sw"].ToString(), out double viewport_x_sw);
                 double.TryParse(reader["viewport_y_sw"].ToString(), out double viewport_y_sw);
                 location.Latitude   = latitude;
                 location.Longitude  = longitude;
                 location.LatitudeM  = latm;
                 location.LongitudeM = longm;
                 if (location.ViewPort == null)
                 {
                     location.ViewPort = new GeoResponse.CResult.CGeometry.CViewPort
                     {
                         NorthEast = new GeoResponse.CResult.CGeometry.CLocation(),
                         SouthWest = new GeoResponse.CResult.CGeometry.CLocation()
                     };
                 }
                 location.ViewPort.NorthEast.Lat  = viewport_y_ne;
                 location.ViewPort.NorthEast.Long = viewport_x_ne;
                 location.ViewPort.SouthWest.Lat  = viewport_y_sw;
                 location.ViewPort.SouthWest.Long = viewport_x_sw;
                 location.GeocodeStatus           = (FactLocation.Geocode)Enum.Parse(typeof(FactLocation.Geocode), reader["geocodestatus"].ToString());
                 location.FoundLocation           = reader["foundlocation"].ToString();
                 location.FoundResultType         = reader["foundresulttype"].ToString();
                 int.TryParse(reader["foundlevel"].ToString(), out int foundlevel);
                 location.FoundLevel = foundlevel;
             }
         }
     }
 }
Ejemplo n.º 9
0
 public EditLocation(FactLocation location)
 {
     InitializeComponent();
     customMapLayers = new List <GdalRasterLayer>();
     mnuMapStyle.Setup(linkLabel1, mapBox1, tbOpacity);
     mapZoomToolStrip.Items.Add(mnuMapStyle);
     mapZoomToolStrip.Items[2].ToolTipText = "Zoom out of Map"; // fix bug in SharpMapUI component
     mapZoomToolStrip.Items[10].Visible    = false;
     this.location        = location;
     originalLocation     = FactLocation.TEMP;
     btnCustomMap.Visible = (Properties.MappingSettings.Default.CustomMapPath.Length > 0);
     FactLocation.CopyLocationDetails(location, originalLocation);
     Text           = "Editing : " + location.ToString();
     iconSelected   = false;
     pointUpdated   = false;
     dataUpdated    = false;
     UserSavedPoint = false;
     SetupMap();
     SetLocation();
 }
Ejemplo n.º 10
0
        private void tsBtnMapOSLocation_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            CensusIndividual ds  = dgCensus.CurrentRow == null ? null : (CensusIndividual)dgCensus.CurrentRow.DataBoundItem;
            FactLocation     loc = ds == null ? null : ds.CensusLocation;

            if (loc != null)
            {   // Do geo coding stuff
                BingOSMap frmBingMap = new BingOSMap();
                if (frmBingMap.SetLocation(loc, loc.Level))
                {
                    frmBingMap.Show();
                }
                else
                {
                    MessageBox.Show("Unable to find location : " + loc.ToString(), "FTAnalyzer");
                }
            }
            this.Cursor = Cursors.Default;
        }
Ejemplo n.º 11
0
        public static void UpdateGeocode(FactLocation loc)
        {
            if (InstanceConnection.State != ConnectionState.Open)
            {
                InstanceConnection.Open();
            }
            using (SQLiteCommand updateCmd = new SQLiteCommand("update geocode set founddate=date('now'), level = ?, latitude = ?, longitude = ?, foundlocation = ?, foundlevel = ?, viewport_x_ne = ?, viewport_y_ne = ?, viewport_x_sw = ?, viewport_y_sw = ?, geocodestatus = ?, foundresulttype = ?, latm = ?, longm = ? where location = ?", InstanceConnection))
            {
                SQLiteParameter param = updateCmd.CreateParameter();
                param.DbType = DbType.Int32;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.Double;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.Double;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.String;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.Int32;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.Double;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.Double;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.Double;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.Double;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.Int32;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.String;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.Double;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.Double;
                updateCmd.Parameters.Add(param);

                param        = updateCmd.CreateParameter();
                param.DbType = DbType.String;
                updateCmd.Parameters.Add(param);

                updateCmd.Prepare();

                updateCmd.Parameters[0].Value  = loc.Level;
                updateCmd.Parameters[1].Value  = loc.Latitude;
                updateCmd.Parameters[2].Value  = loc.Longitude;
                updateCmd.Parameters[3].Value  = loc.FoundLocation;
                updateCmd.Parameters[4].Value  = loc.FoundLevel;
                updateCmd.Parameters[5].Value  = loc.ViewPort.NorthEast.Long;
                updateCmd.Parameters[6].Value  = loc.ViewPort.NorthEast.Lat;
                updateCmd.Parameters[7].Value  = loc.ViewPort.SouthWest.Long;
                updateCmd.Parameters[8].Value  = loc.ViewPort.SouthWest.Lat;
                updateCmd.Parameters[9].Value  = loc.GeocodeStatus;
                updateCmd.Parameters[10].Value = loc.FoundResultType;
                updateCmd.Parameters[11].Value = loc.LatitudeM;
                updateCmd.Parameters[12].Value = loc.LongitudeM;
                updateCmd.Parameters[13].Value = loc.ToString();
                int rowsaffected = updateCmd.ExecuteNonQuery();
                if (rowsaffected != 1)
                {
                    Console.WriteLine("Problem updating");
                }
                OnGeoLocationUpdated(loc);
            }
        }
Ejemplo n.º 12
0
        public static void InsertGeocode(FactLocation loc)
        {
            if (InstanceConnection.State != ConnectionState.Open)
            {
                InstanceConnection.Open();
            }
            SQLiteParameter param;

            using (SQLiteCommand insertCmd = new SQLiteCommand("insert into geocode (location, level, latitude, longitude, founddate, foundlocation, foundlevel, viewport_x_ne, viewport_y_ne, viewport_x_sw, viewport_y_sw, geocodestatus, foundresulttype, latm, longm) values(?,?,?,?,date('now'),?,?,?,?,?,?,?,?,?,?)", InstanceConnection))
            {
                param        = insertCmd.CreateParameter();
                param.DbType = DbType.String;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.Int32;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.Double;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.Double;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.String;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.Int32;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.Double;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.Double;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.Double;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.Double;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.Int32;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.String;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.Double;
                insertCmd.Parameters.Add(param);

                param        = insertCmd.CreateParameter();
                param.DbType = DbType.Double;
                insertCmd.Parameters.Add(param);

                insertCmd.Prepare();

                insertCmd.Parameters[0].Value  = loc.ToString();
                insertCmd.Parameters[1].Value  = loc.Level;
                insertCmd.Parameters[2].Value  = loc.Latitude;
                insertCmd.Parameters[3].Value  = loc.Longitude;
                insertCmd.Parameters[4].Value  = loc.FoundLocation;
                insertCmd.Parameters[5].Value  = loc.FoundLevel;
                insertCmd.Parameters[6].Value  = loc.ViewPort.NorthEast.Long;
                insertCmd.Parameters[7].Value  = loc.ViewPort.NorthEast.Lat;
                insertCmd.Parameters[8].Value  = loc.ViewPort.SouthWest.Long;
                insertCmd.Parameters[9].Value  = loc.ViewPort.SouthWest.Lat;
                insertCmd.Parameters[10].Value = loc.GeocodeStatus;
                insertCmd.Parameters[11].Value = loc.FoundResultType;
                insertCmd.Parameters[12].Value = loc.LatitudeM;
                insertCmd.Parameters[13].Value = loc.LongitudeM;

                int rowsaffected = insertCmd.ExecuteNonQuery();
            }
        }
Ejemplo n.º 13
0
        public void SetLocation(FactLocation loc, int level)
        {
            peopleWindow.Window.Title = "Individuals & Families with connection to " + loc.ToString();
            level = Math.Min(loc.Level, level); // if location level isn't as detailed as level on tab use location level
            IEnumerable <Individual> listInd = FamilyTree.Instance.GetIndividualsAtLocation(loc, level);
            SortableBindingList <IDisplayIndividual> dsInd = new SortableBindingList <IDisplayIndividual>();

            foreach (Individual i in listInd)
            {
                dsInd.Add(i);
            }
            peopleView.LoadIndividuals(dsInd);

            IEnumerable <Family> listFam = FamilyTree.Instance.GetFamiliesAtLocation(loc, level);
            SortableBindingList <IDisplayFamily> dsFam = new SortableBindingList <IDisplayFamily>();

            foreach (Family f in listFam)
            {
                dsFam.Add(f);
            }
            peopleView.LoadFamilies(dsFam);
            UpdateStatusCount();
        }