2

I'm writing an event receiver to set a geolocation column. In my library i have columns Wic_System_GPS_Latitude and Wic_System_GPS_Longitude. It retrieves correctly the value of the picture but i need to set geolocation column with

Point(Longitude Latitude)

How convert Wic_System_GPS_Latitude and Wic_System_GPS_Longitude to a correct format for Point

Solution:

I finally found the solution to transform in correct format Here is the code i added in my event receiver:

                    string wicLatitude = (itPicture["wic_System_GPS_Latitude"] != null) ? itPicture["wic_System_GPS_Latitude"].ToString() : string.Empty;
                string wicLongitude = (itPicture["wic_System_GPS_Longitude"] != null) ? itPicture["wic_System_GPS_Longitude"].ToString() : string.Empty;
                string minutes_Long = string.Empty;
                string degre_Long = string.Empty;
                Double longitude = 0;
                string minute_Latitude = string.Empty;
                string degre_Latitude = string.Empty;
                Double latitude = 0;
                if (!string.IsNullOrEmpty(wicLatitude))
                { 
                    minute_Latitude = wicLatitude.Substring(wicLatitude.IndexOf(",")+1,wicLatitude.Length - wicLatitude.IndexOf(",")-2);
                    degre_Latitude = wicLatitude.Substring(0, wicLatitude.IndexOf(","));
                    latitude = Convert.ToDouble(degre_Latitude) + (Convert.ToDouble(minute_Latitude) / 60);
                }
                if (!string.IsNullOrEmpty(wicLongitude))
                {
                    minutes_Long = wicLongitude.Substring(wicLongitude.IndexOf(",") + 1, wicLongitude.Length - wicLongitude.IndexOf(",") - 2);
                    degre_Long = wicLongitude.Substring(0, wicLongitude.IndexOf(","));
                    longitude = Convert.ToDouble(degre_Long) + (Convert.ToDouble(minutes_Long) / 60);
                }
                itPicture["LocationPicture"] = "Point(" + longitude + " " + latitude + ")";

                itPicture.SystemUpdate();
  • Add your edit as an answer instead, so the question can be correctly resolved and so that the solution is easily findable by future readers. – Robert Lindgren Jan 10 '16 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.