From: Ali <agh...@yo...> - 2011-01-28 16:11:22
|
Hi Nick; I just had some progress to complete coding side to read/input a very simple polygon shape file. There is no error. But when I initialize the program, I am not able to see the map. I can add more map to my "display", as you can see I added the red map in display (attached), but not the original map from my file. Please don't ask me how I did this, just to let you know, I used tutorials, samples, your advice,,,. There is also a screen shot from my file which is attached. I need a bit help to be able to read my shape files including attributes in REPAST. Thank you very much for your support Ali Please look at the following codes from "GisAgent.java" and "GISContextCreator.java": GisAgent.java: package gismmv; import java.awt.Color; import org.geotools.referencing.operation.projection.Orthographic; import com.vividsolutions.jts.geom.Geometry; public class GisAgent { model gismodel; private static Orthographic Geometry = null; public void VectorAgent() { /* empty */ } public String[] getProbedProperties() { String[] propNames = null; return propNames; } public void step() { /* empty */ } public void setGeometry(Orthographic omgraphic) { Geometry = omgraphic; } public Orthographic getGeometry() { return Geometry; } public void setArea(double d) { double area = d; } public double getArea() { return getArea(); } public void setBasinnum(int i) { int basinnum = i; } public int getBasinnum() { return getBasinnum(); } public void setPerimeter(double d) { double perimeter = d; } public double getPerimeter() { return getPerimeter(); } public void initDrawingMap() { Color defaultColor = new Color(-65536); Object drawingMap = null; ((GisAgent) drawingMap).clear(); } private void clear() { // TODO Auto-generated method stub } public Color setupDraw() { Color defaultColor = null; return defaultColor; } public void setModel(GISModel gismodel) { GISModel model = gismodel; } public void reset() { // TODO Auto-generated method stub } public void scheduleActionBeginning(double d, GISContextCreator contextCreator, String string) { // TODO Auto-generated method stub } } And the other one which is GISContextCreator.java: package gismmv; import java.util.Iterator; import repast.simphony.context.Context; import repast.simphony.dataLoader.ContextBuilder; public class GISContextCreator implements ContextBuilder<GisAgent> { public class GISModel { } private DefaultGroup vectorAgentGroup; /*synthetic*/ private static Class class$default_package$VectorAgent; public void GISModel() { String[] params = new String[0]; String name = "GIS Model"; } public DefaultGroup getVectorAgentGroup() { return vectorAgentGroup; } public void initAgents() { /* empty */ } public void updateDisplay() { this.updateDisplay(); } public void writeAgents() { /* empty */ } public void _setup() { vectorAgentGroup = new DefaultGroup((class$default_package$VectorAgent != null ? class$default_package$VectorAgent : (class$default_package$VectorAgent = _class$_("default_package.VectorAgent"))), "step"); } /*synthetic*/ static Class _class$_(String string) { Class var_class; try { var_class = Class.forName(string); } catch (ClassNotFoundException classnotfoundexception) { throw new NoClassDefFoundError(classnotfoundexception .getMessage()); } return var_class; } public void _build() { OpenMapData openmapdata = OpenMapData.getInstance(); vectorAgentGroup.addAll (openmapdata.createAgents ((class$default_package$VectorAgent != null ? class$default_package$VectorAgent : (class$default_package$VectorAgent = _class$_("default_package.VectorAgent"))), "D:/Alireza/stuff for Ali Oct 19 2010/Maitland Valley project data Oct 2010/Basin files/Listowel_Middle_Maitland_Basin10.shp")); Iterator iterator = vectorAgentGroup.iterator(); while (iterator.hasNext()) { VectorAgent vectoragent = (VectorAgent) iterator.next(); vectoragent.setModel1(this); } } @Override public Context build(Context<GisAgent> context) { // TODO Auto-generated method stub return null; } } |