コード例 #1
0
        public void Build()
        {
            qGis_Object[] objects = null;

            if (SearchID > 0) objects = qGis_Object.GetObjects (Boundary, SearchID);
            else objects = qGis_Object.GetObjects(Boundary);

            if (objects == null) return;

            qGis_ClientRule rule = new qGis_ClientRule(RuleID);

            double long_step = Boundary.Width / rule.GridHorizontalDivisions;
            double lat_step = Boundary.Height / rule.GridVerticalDivisions;

            qGis_Cluster [] temp_clusters = new qGis_Cluster [rule.GridHorizontalDivisions * rule.GridVerticalDivisions];

            foreach (qGis_Object gis_object in objects)
            {
                for (int row = 0; row < rule.GridVerticalDivisions; row++)
                {
                    for (int col = 0; col < rule.GridHorizontalDivisions; col++)
                    {
                        double left = Boundary.NorthWest.Longitude + col * long_step;
                        double right = left + long_step;
                        double top = Boundary.NorthWest.Latitude - row * lat_step;
                        double bottom = top - lat_step;

                        if (gis_object.Latitude > top || gis_object.Latitude < bottom) break;
                        if (gis_object.Longitude > right || gis_object.Longitude < left) continue;

                        if (temp_clusters [row * col] == null) temp_clusters[row * col] = new qGis_Cluster(gis_object.Longitude, gis_object.Latitude);

                        temp_clusters[row * col].AddObject (gis_object);
                    }
                }
            }

            List<qGis_Cluster> clusters = new List<qGis_Cluster>();

            for (int i = temp_clusters.Length - 1; i >= 0; i--)
                if (temp_clusters[i] != null)
                    clusters.Add(temp_clusters[i]);

            Clusters = clusters.ToArray();
        }
コード例 #2
0
        public void Build()
        {
            qGis_Object[] objects = null;

            if (SearchID > 0)
            {
                objects = qGis_Object.GetObjects(Boundary, SearchID);
            }
            else
            {
                objects = qGis_Object.GetObjects(Boundary);
            }

            if (objects == null)
            {
                return;
            }

            qGis_ClientRule rule = new qGis_ClientRule(RuleID);

            double long_step = Boundary.Width / rule.GridHorizontalDivisions;
            double lat_step  = Boundary.Height / rule.GridVerticalDivisions;

            qGis_Cluster [] temp_clusters = new qGis_Cluster [rule.GridHorizontalDivisions * rule.GridVerticalDivisions];

            foreach (qGis_Object gis_object in objects)
            {
                for (int row = 0; row < rule.GridVerticalDivisions; row++)
                {
                    for (int col = 0; col < rule.GridHorizontalDivisions; col++)
                    {
                        double left   = Boundary.NorthWest.Longitude + col * long_step;
                        double right  = left + long_step;
                        double top    = Boundary.NorthWest.Latitude - row * lat_step;
                        double bottom = top - lat_step;

                        if (gis_object.Latitude > top || gis_object.Latitude < bottom)
                        {
                            break;
                        }
                        if (gis_object.Longitude > right || gis_object.Longitude < left)
                        {
                            continue;
                        }

                        if (temp_clusters [row * col] == null)
                        {
                            temp_clusters[row * col] = new qGis_Cluster(gis_object.Longitude, gis_object.Latitude);
                        }

                        temp_clusters[row * col].AddObject(gis_object);
                    }
                }
            }

            List <qGis_Cluster> clusters = new List <qGis_Cluster>();

            for (int i = temp_clusters.Length - 1; i >= 0; i--)
            {
                if (temp_clusters[i] != null)
                {
                    clusters.Add(temp_clusters[i]);
                }
            }

            Clusters = clusters.ToArray();
        }