Exemplo n.º 1
0
    public int getScale(GridCluster cluster, int totalNumPoints)
    {
        int scaleMin = 5;
        int scaleMax = 40;
        int scale;

        int clusterPoints = cluster.getNumPoints();

        scale = scaleMin + (int)((3 * scaleMax * clusterPoints) / totalNumPoints);

        if (!cluster.isGroupPoints())
        {
            scale = scale / 4;
        }

        return(20); // scale;
    }
Exemplo n.º 2
0
    public void managePointsNew(GridCluster cluster)
    {
        int             i      = 0;
        List <MapPoint> points = cluster.getPoints();

        //Debug.Log("Managin cluster with " + points.Count);

        int numPoints = points.Count;

        List <GridCluster> newClusters = new List <GridCluster>();
        float   width  = (cluster.maxX - cluster.minX) / 2.5f;
        float   heigth = cluster.maxY - cluster.minY;
        Vector2 size   = new Vector2(width, heigth);

        if (size.x != 0.0f)
        {
            Rect area1 = new Rect(new Vector2(cluster.minX, cluster.minY), size);
            //Rect area2 = new Rect(new Vector2(cluster.minX + (cluster.maxX - cluster.minX) / 3.0f, cluster.minY), size);
            Rect area3 = new Rect(new Vector2(cluster.maxX - (cluster.maxX - cluster.minX) / 3.0f, cluster.minY), size);

            Vector2 center1 = getRectCenter(area1);
            //Vector2 center2 = getRectCenter(area2);
            Vector2 center3 = getRectCenter(area3);

            GridCluster cluster1 = new GridCluster(0, 0); // this.getHGrid(center1.x), this.getVGrid(center1.y));
                                                          // GridCluster cluster2 = new GridCluster(0,0); //;this.getHGrid(center2.x), this.getVGrid(center2.y));
            GridCluster cluster3 = new GridCluster(0, 0); // this.getHGrid(center3.x), this.getVGrid(center3.y));

            for (i = 0; i < numPoints; i++)
            {
                MapPoint p = cluster.getPoints()[i];

                if (isInRect(p.getX(), p.getY(), area1))
                {
                    p.addCluster(cluster1);
                    cluster1.addPoint(p);
                }
                else
                {
                    /*
                     * if (isInRect(p.getX(), p.getY(), area2))
                     * {
                     *  p.addCluster(cluster2);
                     *  cluster2.addPoint(p);
                     * }
                     * else
                     * {*/
                    p.addCluster(cluster3);
                    cluster3.addPoint(p);
                    //}
                }
            }

            int numclusters = 0;

            if (cluster1.getNumPoints() > 0)
            {
                cluster1.setParent(cluster);
                cluster1.setLevel(this.level);
                cluster.addChild(cluster1);
                this.clusters.Add(cluster1);
                numclusters++;
            }

            /*
             * if (cluster2.getNumPoints() > 0)
             * {
             *  cluster2.setParent(cluster);
             *  cluster.addChild(cluster2);
             *  cluster2.setLevel(this.level);
             *  this.clusters.Add(cluster2);
             *  numclusters++;
             * }*/

            if (cluster3.getNumPoints() > 0)
            {
                cluster3.setParent(cluster);
                cluster.addChild(cluster3);
                cluster3.setLevel(this.level);
                this.clusters.Add(cluster3);
                numclusters++;
            }
            //Debug.Log("Se crean "+ numclusters+ " clusters normales en nivel " + this.level);
        }
        else // grouppoint o clusters de 1 punto
        {
            //Debug.Log("Se crea un cluster de grouppoint/1 punto en nivel " + this.level);
            GridCluster cluster1 = new GridCluster(0, 0, cluster.getPoints()[0]);
            cluster1.setLevel(this.level);
            cluster1.setParent(cluster);
            cluster.addChild(cluster1);
            this.clusters.Add(cluster1);
        }
    }