Ejemplo n.º 1
0
 public GridCluster(GridCluster a)
 {
     this.numFilteredPoints = 0;
     this.points.AddRange(a.getPoints());
     a.setParent(this);
     this.addChild(a);
     this.center = new MapPoint(a.getCenter().getX(), a.getCenter().getY());
 }
Ejemplo n.º 2
0
    private OnlineMapsDrawingLine addConnection(GridCluster clusterFrom, GridCluster clusterTo, int numConnections)
    {
        MapPoint from = clusterFrom.getCenter();
        MapPoint to   = clusterTo.getCenter();


        List <Vector2> points = new List <Vector2>();

        points.Add(from.getVector2());
        points.Add(to.getVector2());



        OnlineMapsDrawingLine oLine = new OnlineMapsDrawingLine(points, Color.blue);

        oLine.width   = 1.0f;
        oLine.visible = true;
        OnlineMapsDrawingElementManager.AddItem(oLine);
        oLine.visible = false;
        oLine.name    = "connection";



        return(oLine);
    }
Ejemplo n.º 3
0
 public GridCluster(GridCluster a, GridCluster b)
 {
     this.numFilteredPoints = 0;
     this.points.AddRange(a.getPoints());
     this.points.AddRange(b.getPoints());
     a.setParent(this);
     b.setParent(this);
     this.addChild(a);
     this.addChild(b);
     this.setAverageCenter(a.getCenter(), b.getCenter());
 }
Ejemplo n.º 4
0
    protected MapPointMarker getClusterMarker(GridCluster gCluster, int id)
    {
        MapPointMarker mapPoint = new MapPointMarker(gCluster.getCenter().getX(), gCluster.getCenter().getY(), clusterPrefab, true);

        mapPoint.setGridCluster(gCluster);
        mapPoint.setLabel("Cluster " + id);

        //if(mapPoint.getMarker3D()!= null)
        //    mapPoint.getMarker3D().instance.name = id.ToString();


        mapPoint.setClusteredPoints(gCluster.getPoints());

        mapPoint.setCluster(true);
        if (mapPoint.getMarker3D() != null)
        {
            mapPoint.getMarker3D().altitude     = 30.0f;
            mapPoint.getMarker3D().altitudeType = OnlineMapsAltitudeType.absolute;
            mapPoint.getMarker3D().scale        = getScale(gCluster, this.points.Count);
        }

        mapPoint.setMap(this);



        addMarkerInstance(mapPoint);


        if (mapPoint.isGroupPoint())
        {
            var img = mapPoint.markerInstance.gameObject.GetComponentInChildren <Image>();
            if (img != null)
            {
                img.sprite = customGroupPointMarker;
                foreach (var imgchild in img.GetComponentsInChildren <Image>())
                {
                    if (imgchild != img)
                    {
                        imgchild.sprite = customGroupPointMarker;
                    }
                }
            }
        }

        gCluster.setCenter(mapPoint);

        //if (gCluster.isGroupPoints())
        //    Debug.Log("AQUI");

        /*
         *
         * if (gCluster.getCategory().Equals("silknow.org/#pthing"))
         * {
         *  SphereCollider sphereCollider = mapPoint.getMarker3D().instance.GetComponent<SphereCollider>();
         *  sphereCollider.radius = 1;
         *  //mapPoint.getMarker3D().scale = mapPoint.getMarker3D().scale * 100.0f;
         * }
         * else
         * {
         *  CapsuleCollider capsuleCollider = mapPoint.getMarker3D().instance.GetComponent<CapsuleCollider>();
         *  capsuleCollider.radius = 0.5f;
         *  capsuleCollider.height = 1.5f;
         *  capsuleCollider.direction = 1;
         *  mapPoint.getMarker3D().altitude = 70.0f;
         *  //mapPoint.getMarker3D().transform.position = mapPoint.getMarker3D().transform.position + new Vector3(0.0f, 60.0f, 0.0f);
         *  //mapPoint.getMarker3D().al
         *
         * }*/



        mapPoint.hide();

        return(mapPoint);
    }
Ejemplo n.º 5
0
    protected GridCluster getClosestTo(GridCluster from, List <GridCluster> clusterList, int since, float minimum, bool check)
    {
        GridCluster closest  = null;
        GridCluster closest1 = null;
        string      fromURI  = from.getPoints()[0].getURI();

        float minDistance  = 1000000.0f;
        float minDistance1 = 1000000.0f;
        //float minimum = 5.0f;

        int i = since;

        //i = 0;

        while (i < clusterList.Count)
        {
            if (!clusterList[i].processed && from != clusterList[i])  //&& clusterList[i].getNumPoints()>1)
            {
                float currentDistance = getDistance(from.getCenter(), clusterList[i].getCenter());

                if (currentDistance <= minimum)
                {
                    if (check)
                    {
                        //GridCluster closest2 = getClosestTo(clusterList[i], clusterList, since, minimum, false);

                        GridCluster closest2 = clusterList[i].closest;

                        if (closest2 != null)
                        {
                            if (closest2.getPoints()[0].getURI().Equals(fromURI))
                            {
                                if (currentDistance < minDistance && clusterList[i].getNumPoints() >= 1)
                                {
                                    minDistance = currentDistance;
                                    closest     = clusterList[i];
                                }

                                /*
                                 * if (currentDistance < minDistance1 && clusterList[i].getNumPoints() == 1)
                                 * {
                                 *  minDistance1 = currentDistance;
                                 *  closest1 = clusterList[i];
                                 * }*/
                            }
                        }
                    }
                    else
                    {
                        if (currentDistance < minDistance && clusterList[i].getNumPoints() >= 1)
                        {
                            minDistance = currentDistance;
                            closest     = clusterList[i];
                        }

                        /*
                         * if (currentDistance < minDistance1 && clusterList[i].getNumPoints() == 1)
                         * {
                         *  minDistance1 = currentDistance;
                         *  closest1 = clusterList[i];
                         * }*/
                    }
                }
            }

            i++;
        }

        //if (minDistance1 < minDistance / 1.25f)
        //  closest = closest1;

        return(closest);
    }