示例#1
0
        /// <summary>
        /// Populate the variables available from the selected site
        /// layer, the polygon layer, and the selected polygons in
        /// the map within this layer.
        /// </summary>
        private void populateVariables()
        {
            polygonData.Clear();

            foreach (IFeature polygon in polygons.Features)
            {
                PolygonData data = new PolygonData();
                data.polygon = polygon;

                IMapPointLayer pointLayer = ((KeyValuePair <IMapPointLayer, string>)SiteList.SelectedItem).Key;
                var            features   = pointLayer.DataSet.Features;

                foreach (IFeature point in features)
                {
                    if (point.Intersects(polygon))
                    {
                        SiteData siteData = new SiteData();
                        siteData.site = point;

                        foreach (var fld in point.ParentFeatureSet.GetColumns())
                        {
                            var getColumnValue = (Func <string, string>)(column => (point.DataRow[column].ToString()));
                            var strValue       = getColumnValue(fld.ColumnName);

                            switch (fld.ColumnName)
                            {
                            case "SiteCode":
                                siteData.siteCode = strValue;
                                break;

                            case "VarCode":
                                siteData.variableCode = strValue;
                                break;

                            case "VarName":
                                siteData.variableName = strValue;
                                break;
                            }
                        }

                        data.sites.Add(siteData);
                        variables.Add(siteData.variableName);
                    }
                }

                polygonData.Add(data);
            }

            if (variables.Count > 0)
            {
                VariableList.DataSource = new BindingSource(variables, null);
            }
        }
示例#2
0
        /// <summary>
        /// This function gets the data values.
        /// </summary>
        private DataTable getAverageTable(PolygonData polygon)
        {
            var query =
                "SELECT DataValues.LocalDateTime, AVG(DataValues.DataValue) FROM DataValues"
                + " LEFT JOIN DataSeries ON DataValues.SeriesID == DataSeries.SeriesID"
                + " LEFT JOIN Variables ON DataSeries.VariableID == Variables.VariableID"
                + " WHERE DataValues.SeriesID IN ({0}) AND DataValues.DataValue != Variables.NoDataValue"
                + " GROUP BY DataValues.LocalDateTime";
            var       formatted = String.Format(query, String.Join(",", polygon.dataSeries.ToArray()));
            DataTable result    = dbOperations.LoadTable(formatted);

            return(result);
        }
示例#3
0
        /// <summary>
        /// This function gets the serie's ids.
        /// </summary>
        private void getSeriesID(int siteID, int variableID, PolygonData polygon)
        {
            var query =
                "SELECT SeriesID FROM DataSeries WHERE SiteID = '"
                + siteID + "'" +
                "AND VariableID = '"
                + variableID + "'";
            DataTable result = dbOperations.LoadTable(query);

            foreach (DataRow row in result.Rows)
            {
                polygon.dataSeries.Add(Convert.ToInt32(row.ItemArray.First()));
            }
        }
示例#4
0
        /// <summary>
        /// This function gets the time series (date - value)
        /// </summary>
        private Series getSeriesFromTable(PolygonData polygon)
        {
            DataTable averageTable = getAverageTable(polygon);
            Series    series       = new Series();

            series.Site = getSitesParameters(polygon);
            var site = polygon.sites.Find(f => f.variableName == VariableList.SelectedValue.ToString());

            series.Variable            = getVariablesParameters(site.variableID);
            series.CreationDateTime    = DateTime.Now;
            series.LastCheckedDateTime = DateTime.Now;
            series.UpdateDateTime      = DateTime.Now;

            foreach (DataRow row in averageTable.Rows)
            {
                series.AddDataValue((DateTime)row["LocalDateTime"], (Double)row["AVG(DataValues.DataValue)"]);
            }
            return(series);
        }
示例#5
0
        /// <summary>
        /// This function gets the site information.
        /// </summary>
        private Site getSitesParameters(PolygonData polygon)
        {
            IFeature centroid = polygon.polygon.Centroid();
            var      newpoint = sitesPoints.AddFeature(centroid);

            Site   site             = new Site();
            var    xy               = new[] { centroid.Coordinates.First().X, centroid.Coordinates.First().Y };
            String projectionString = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[" +
                                      "\"WGS_1984\",6378137,298.257223562997]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]";
            var _wgs84Projection = ProjectionInfo.FromEsriString(projectionString);

            Reproject.ReprojectPoints(xy, new double[] { 0, 0 }, App.Map.Projection, _wgs84Projection, 0, 1);

            int indexNumber = (polygonData.IndexOf(polygon) + 1);

            site.Code = "CrwrAggregation:" + OutputResultName.Text + indexNumber.ToString();
            newpoint.DataRow.BeginEdit();
            newpoint.DataRow["SiteCode"] = site.Code.ToString();
            newpoint.DataRow.EndEdit();

            site.Name      = OutputResultName.Text + indexNumber.ToString();
            site.Latitude  = xy[1];
            site.Longitude = xy[0];
            //site.Elevation_m = 12;
            site.VerticalDatum = "Unkown";
            //site.LocalX = 12;
            //site.LocalY = 12;
            //site.PosAccuracy_m = 12;
            site.State  = "";
            site.County = "";
            //site.Comments = "testing";
            //site.Country = "Mexico";
            //site.SiteType = "Type";

            return(site);
        }