Neighbourhood spatial query

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Neighbourhood spatial query

cnietocoria
Hello,

My model consist in load from a shapefile a hexagonal grid. Each hexagon in the grid is an Agent.
In the following method, I created the neighbourhood of each hexagon. And storing it in a List, actually I created two list; one for the geometry itself and the second is for the ID of each hexagon that belongs to the neighbourhood.  

I need to sort the list. Because I would like to perform different actions depending of which direction is located the neighbour.
However, each hexagon's ID is not correlative then I cannot in order to sort by ID. I have been trying to figure it out how the query analyses. Although, I was not successful.

Does exist the way to know in which direction is located each hexagon?
 

public void Neighbourhood(){

        Context context = ContextUtils.getContext(this);
        Geography<Hexagon> geography = (Geography)context.getProjection("Geography");
        Geometry hexagon = geography.getGeometry(this);
        GeographyWithin<Hexagon> within = new GeographyWithin<Hexagon>(geography, distance , this);
        if( within.query() != null ){
           
            for (Hexagon obj: within.query()){

                neighbours.add(obj);
                idList.add(obj.ID);   
            }

        }else{
            System.out.println("ERROR: Hexagon "+this.ID+" has not neighbours! ");
        }
    }

Thanks in advance,

Cesar

--
--------------------------------------------------------------
PhD. Student at University of Camerino
Ing. Cesar Augusto Nieto Coria
skype: cnietocoria


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest