Exemplo n.º 1
0
    public void update()
    {
        int      i         = 0;
        MapLevel lastLevel = null;


        //List<MapPoint> levelPoints = this.points;

        //Debug.Log("Actualizando para " + points.Count + "");


        for (i = 0; i < zoomIntervals; i++)
        {
            this.levels.Add(new MapLevel(this.zone, this.numQuadsHoriz, this.numQuadsVert, i));
        }


        for (i = zoomIntervals - 2; i >= 0; i--)
        {
            int numClos = 0;

            int punto1 = 0;
            //MapLevel level = new MapLevel(this.zone, this.numQuadsHoriz, this.numQuadsVert, i);
            MapLevel level = this.levels[i];


            if (lastLevel == null)
            {
                //Debug.Log("Hay "+ this.pointGroups.Count+" gouppoints");


                for (int pG = 0; pG < this.pointGroups.Count; pG++)
                {
                    this.pointGroups[pG].setLevel(level);
                    level.addCluster(this.pointGroups[pG]);
                    //this.pointGroups[pG].processed = true;
                }
                level.managePoints(this.points, 0.5f);
            }
            else
            {
                List <GridCluster> clusterList = lastLevel.getGridClusters();// this.getGridClustersAtLevel(i+1);
                //Debug.Log("EN ZOOM INTERVAL " + i + "y nivel " + lastLevel.getLevel() + " hay ....");
                //Debug.Log("EN nivel " + lastLevel.getLevel() + " hay " + clusterList.Count + " clusters");

                //Debug.Log("El minimio del nivel " + lastLevel.getLevel() + " es " + level.getMinimum());
                if (clusterList != null)
                {
                    if (clusterList.Count == 1)
                    {
                        //Debug.Log("UNO Y SALE");
                        GridCluster newGridCluster = new GridCluster(clusterList[0]);
                        newGridCluster.associatePoints();
                        //newGridCluster.update();
                        level.addCluster(newGridCluster);
                    }
                    else
                    {
                        float minimum = level.getMinimum();

                        if (level.getLevel() <= 1)
                        {
                            minimum = minimum * 100.0f;
                        }

                        //for (int o = 0;o<clusterList.Count;o++)
                        //  clusterList[o].closest = getClosestTo(clusterList[o], clusterList, 0, minimum, false);

                        int aux = 0;
                        while (aux < clusterList.Count)
                        {
                            GridCluster currentCluster = clusterList[aux];
                            if (!clusterList[aux].processed)
                            {
                                if (clusterList[aux].getPoints()[0].getURI().Equals(("http://data.silknow.org/object/5f7a48fe-d8ac-37d8-90e3-f4448e665a9b")))
                                {
                                    Debug.Log("Procesando");
                                }
                                GridCluster closest = getClosestTo(clusterList[aux], clusterList, aux, minimum, false);

                                if (closest != null)
                                {
                                    GridCluster newGridCluster = new GridCluster(currentCluster, closest);
                                    newGridCluster.associatePoints();
                                    newGridCluster.update();
                                    level.addCluster(newGridCluster);
                                    currentCluster.processed = true;
                                    closest.processed        = true;
                                    numClos++;
                                }
                                else
                                {
                                    GridCluster newGridCluster = new GridCluster(currentCluster);
                                    newGridCluster.associatePoints();
                                    //newGridCluster.update();
                                    level.addCluster(newGridCluster);
                                    currentCluster.processed = true;
                                    punto1++;
                                }

                                /*
                                 * }
                                 * else
                                 * {
                                 *  GridCluster newGridCluster = new GridCluster(currentCluster);
                                 *  newGridCluster.associatePoints();
                                 *  //newGridCluster.update();
                                 *  level.addCluster(newGridCluster);
                                 *  currentCluster.processed = true;
                                 *  punto1++;
                                 *  //closest.processed = true;
                                 * }*/
                            }
                            aux++;
                        }
                    }
                }
                //Debug.Log("EN el nivel " + i + " hay " + level.getGridClusters().Count);
                //Debug.Log("De los cuales " + punto1 + " son de 1 punto");
            }

            //Debug.Log(numClos + " clusters cercanos");
            lastLevel = level;

            //this.levels.Add(level);
        }

        for (int p = 0; p < points.Count; p++)
        {
            if (points[p].getURI().Equals("http://data.silknow.org/object/54e7582f-d37e-3e85-9cac-c26b52a7711b"))
            {
                MapPoint pn = points[p];
            }

            if (points[p].getURI().Equals("http://data.silknow.org/object/12eed6aa-578c-39c0-b0d8-ecf3cdfd68c8"))
            {
                MapPoint pn = points[p];
            }

            if (points[p].getURI().Equals("http://data.silknow.org/object/db5ed89d-fac0-3cf1-81ec-fc55a66b8252"))
            {
                MapPoint pn = points[p];
            }
        }
    }