示例#1
0
        public static SiteInfoType row2SiteInfoElement(siteInfoDataSet.sitesRow row, siteInfoDataSet ds)
        {
            SiteInfoType sit = CuahsiBuilder.CreateASiteInfoTypeWithLatLongPoint();

            sit.siteName = !String.IsNullOrEmpty(row.SiteName) ? row.SiteName : null;

            // sit created with a single siteCode
            sit.siteCode[0].siteID = row.SiteID.ToString();
            sit.siteCode[0].Value  = !String.IsNullOrEmpty(row.SiteCode) ? row.SiteCode : null;
            string siteNetwork = System.Configuration.ConfigurationManager.AppSettings["network"];

            sit.siteCode[0].network = siteNetwork;

            // we have a point
            ((LatLonPointType)sit.geoLocation.geogLocation).latitude  = row.Latitude;
            ((LatLonPointType)sit.geoLocation.geogLocation).longitude = row.Longitude;
            if (row.LatLongDatumID == 0)
            {
                ((LatLonPointType)sit.geoLocation.geogLocation).srs =
                    ConfigurationManager.AppSettings["defaultSpatialReferenceSystemSRS"];
            }
            else
            {
                siteInfoDataSet.SpatialReferencesRow[] datum =
                    (siteInfoDataSet.SpatialReferencesRow[])ds.SpatialReferences.Select("SpatialReferenceID = " + row.LatLongDatumID);
                if (datum.Length > 0 && !datum[0].IsSRSIDNull())
                {
                    ((LatLonPointType)sit.geoLocation.geogLocation).srs =
                        ConfigurationManager.AppSettings["SRSPrefix"] + datum[0].SRSID;
                }
            }

            if (!row.IsElevation_mNull())
            {
                sit.elevation_m          = row.Elevation_m;
                sit.elevation_mSpecified = true;

                if (!row.IsVerticalDatumNull())
                {
                    sit.verticalDatum = row.VerticalDatum;
                }
            }


            if (!row.IsLocalXNull() && !row.IsLocalYNull() && !row.IsLocalProjectionIDNull())
            {
                sit.geoLocation.localSiteXY = new SiteInfoTypeGeoLocationLocalSiteXY[1];
                SiteInfoTypeGeoLocationLocalSiteXY xy = new SiteInfoTypeGeoLocationLocalSiteXY();
                xy.X = row.LocalX;
                xy.Y = row.LocalY;
                //@TODO local XY
                siteInfoDataSet.SpatialReferencesRow[] datum =
                    (siteInfoDataSet.SpatialReferencesRow[])ds.SpatialReferences.Select("SpatialReferenceID = " + row.LocalProjectionID);
                if (datum.Length > 0)
                {
                    if (!String.IsNullOrEmpty(datum[0].SRSName))
                    {
                        xy.projectionInformation = datum[0].SRSName;
                    }
                    else
                    {
                        xy.projectionInformation = ConfigurationManager.AppSettings["SRSPrefix"] + datum[0].SRSID;
                    }
                }

                sit.geoLocation.localSiteXY[0] = xy;
            }
            if (!row.IsCountyNull())
            {
                NoteType aNote =
                    CuahsiBuilder.createNote(row.County, "County", null);
                sit.note = CuahsiBuilder.addNote(sit.note, aNote);
            }
            if (!row.IsStateNull())
            {
                NoteType aNote =
                    CuahsiBuilder.createNote(row.State, "State", null);
                sit.note = CuahsiBuilder.addNote(sit.note, aNote);
            }
            if (!row.IsCommentsNull())
            {
                NoteType aNote =
                    CuahsiBuilder.createNote(row.Comments, "Site Comments", null);
                sit.note = CuahsiBuilder.addNote(sit.note, aNote);
            }
            return(sit);
        }
            public static SiteInfoType row2SiteInfoElement(siteInfoDataSet.sitesRow row, siteInfoDataSet ds)
            {
                SiteInfoType sit = CuahsiBuilder.CreateASiteInfoTypeWithLatLongPoint();

                sit.siteName = row.SiteName;

                // sit created with a single siteCode
                sit.siteCode[0].siteID          = row.SiteID;
                sit.siteCode[0].siteIDSpecified = true;
                sit.siteCode[0].Value           = row.SiteCode;
                string siteNetwork = System.Configuration.ConfigurationManager.AppSettings["network"];

                sit.siteCode[0].network = siteNetwork;

                // we ALWAYS have a point in ODM 1.1

                /* just check to make sure that they are not the defaults
                 * Should validate thet they are inwithin +-180/+-90
                 * */
                if (!row.Longitude.Equals(0) && !row.Latitude.Equals(0))
                {
                    ((LatLonPointType)sit.geoLocation.geogLocation).latitude  = row.Latitude;
                    ((LatLonPointType)sit.geoLocation.geogLocation).longitude = row.Longitude;
                    if (row.LatLongDatumID.Equals(0))
                    {
                        ((LatLonPointType)sit.geoLocation.geogLocation).srs =
                            ConfigurationManager.AppSettings["defaultSpatialReferenceSystemSRS"];
                    }
                    else
                    {
                        siteInfoDataSet.SpatialReferencesRow[] datum =
                            (siteInfoDataSet.SpatialReferencesRow[])ds.SpatialReferences.Select("SpatialReferenceID = " + row.LatLongDatumID);
                        if (datum.Length > 0)
                        {
                            if (!datum[0].IsSRSIDNull())
                            {
                                ((LatLonPointType)sit.geoLocation.geogLocation).srs =
                                    ConfigurationManager.AppSettings["SRSPrefix"] + datum[0].SRSID;
                            }
                            else if (!string.IsNullOrEmpty(datum[0].SRSName))
                            {
                                ((LatLonPointType)sit.geoLocation.geogLocation).srs = datum[0].SRSName;
                            }
                        }
                    }
                }
                else
                {
                    sit.geoLocation.geogLocation = null;
                }

                if (!row.IsElevation_mNull())
                {
                    sit.elevation_m          = row.Elevation_m;
                    sit.elevation_mSpecified = true;
                    if (!row.IsVerticalDatumNull())
                    {
                        sit.verticalDatum = row.VerticalDatum;
                    }
                }

                if (!row.IsLocalXNull() && !row.IsLocalYNull() && !row.IsLocalProjectionIDNull())
                {
                    sit.geoLocation.localSiteXY = new SiteInfoTypeGeoLocationLocalSiteXY[1];
                    SiteInfoTypeGeoLocationLocalSiteXY xy = new SiteInfoTypeGeoLocationLocalSiteXY();
                    xy.X = row.LocalX;
                    xy.Y = row.LocalY;
                    //@TODO local XY
                    siteInfoDataSet.SpatialReferencesRow[] datum =
                        (siteInfoDataSet.SpatialReferencesRow[])ds.SpatialReferences.Select("SpatialReferenceID = " + row.LocalProjectionID);
                    if (datum.Length > 0)
                    {
                        if (!String.IsNullOrEmpty(datum[0].SRSName))
                        {
                            xy.projectionInformation = datum[0].SRSName;
                        }
                        else
                        {
                            xy.projectionInformation = "Not Specified";
                        }
                    }

                    sit.geoLocation.localSiteXY[0] = xy;
                }
                if (!row.IsCountyNull())
                {
                    PropertyType aNote =
                        CuahsiBuilder.createProperty(row.County, "County", null);
                    sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote);
                }
                if (!row.IsStateNull())
                {
                    PropertyType aNote =
                        CuahsiBuilder.createProperty(row.State, "State", null);
                    sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote);
                }
                if (!row.IsCommentsNull())
                {
                    PropertyType aNote =
                        CuahsiBuilder.createProperty(row.Comments, "Site Comments", null);
                    sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote);
                }
                if (!row.IsPosAccuracy_mNull())
                {
                    PropertyType aNote =
                        CuahsiBuilder.createProperty(row.PosAccuracy_m.ToString(), "PosAccuracy_m", null);
                    sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote);
                }
                return(sit);
            }