|
@@ -20,13 +20,12 @@ import app.brest.utils.geometry.Shape;
|
|
public class Area implements Serializable {
|
|
public class Area implements Serializable {
|
|
|
|
|
|
protected String mName;
|
|
protected String mName;
|
|
- protected String mResource;
|
|
|
|
- protected int mStage;
|
|
|
|
|
|
+ protected String mResourceName;
|
|
protected Shape mShape = new Shape();
|
|
protected Shape mShape = new Shape();
|
|
protected ArrayList<Place> mPlaces = new ArrayList<Place>();
|
|
protected ArrayList<Place> mPlaces = new ArrayList<Place>();
|
|
|
|
+ protected Resource mResource;
|
|
|
|
|
|
-
|
|
|
|
- public Area(JSONObject root)
|
|
|
|
|
|
+ public Area(JSONObject root, Activity act)
|
|
{
|
|
{
|
|
try {
|
|
try {
|
|
JSONArray ja = root.getJSONArray("coordinates");
|
|
JSONArray ja = root.getJSONArray("coordinates");
|
|
@@ -35,12 +34,12 @@ public class Area implements Serializable {
|
|
mShape.add(new GPSPoint(jaa.getDouble(0), jaa.getDouble(1)));
|
|
mShape.add(new GPSPoint(jaa.getDouble(0), jaa.getDouble(1)));
|
|
}
|
|
}
|
|
mName = root.getString("name");
|
|
mName = root.getString("name");
|
|
- mResource = root.getString("resource");
|
|
|
|
- mStage = Integer.parseInt(root.getString("stage"));
|
|
|
|
|
|
+ mResourceName = root.getString("resource");
|
|
ja = root.getJSONArray("points");
|
|
ja = root.getJSONArray("points");
|
|
for(int i=0; i<ja.length(); i++) {
|
|
for(int i=0; i<ja.length(); i++) {
|
|
mPlaces.add(new Place(ja.getJSONObject(i)));
|
|
mPlaces.add(new Place(ja.getJSONObject(i)));
|
|
}
|
|
}
|
|
|
|
+ mResource = new Resource(mResourceName, act);;
|
|
} catch (JSONException e) {
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -51,15 +50,18 @@ public class Area implements Serializable {
|
|
}
|
|
}
|
|
|
|
|
|
public String getResourceName() {
|
|
public String getResourceName() {
|
|
- return mResource;
|
|
|
|
|
|
+ return mResourceName;
|
|
}
|
|
}
|
|
|
|
|
|
public Resource getResource(Activity act) {
|
|
public Resource getResource(Activity act) {
|
|
- return new Resource(mResource, mStage, act);
|
|
|
|
|
|
+ return mResource;
|
|
}
|
|
}
|
|
|
|
|
|
- public int getStage() {
|
|
|
|
- return mStage;
|
|
|
|
|
|
+
|
|
|
|
+ public int getStage()
|
|
|
|
+ {
|
|
|
|
+ if(mResource==null) return -1;
|
|
|
|
+ return mResource.getStage();
|
|
}
|
|
}
|
|
|
|
|
|
public Shape getShape() {
|
|
public Shape getShape() {
|
|
@@ -91,8 +93,7 @@ public class Area implements Serializable {
|
|
jo.put("points", ja);
|
|
jo.put("points", ja);
|
|
jo.put("coordinates", mShape.getJson());
|
|
jo.put("coordinates", mShape.getJson());
|
|
jo.put("name", mName);
|
|
jo.put("name", mName);
|
|
- jo.put("resource", mResource);
|
|
|
|
- jo.put("stage", ""+mStage);
|
|
|
|
|
|
+ jo.put("resource", mResourceName);
|
|
}catch( Exception e)
|
|
}catch( Exception e)
|
|
{
|
|
{
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|