package com.ahau.againstpestinfo.domain;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 注释:
 *
 * @author fanchunchun
 * @date 2018/5/5
 */

public class PestEnitityList {
    private List<PestEntity> mPestEntities;

    public PestEnitityList() {
    }

    public PestEnitityList(JSONObject jsonObject) {
        try {
            mPestEntities= new ArrayList<PestEntity>();
            if (!jsonObject.isNull("data")) {

                JSONArray PestjsonArray = jsonObject.optJSONArray("data");

	        /* JSONObject dataJsonObject = jsonObject.optJSONObject("data");
				JSONArray AdressjsonArray = dataJsonObject.optJSONArray("addressinfos");*/

                if (PestjsonArray!= null && PestjsonArray.length() > 0) {
                    for (int i = 0; i < PestjsonArray.length(); i++) {
                        if (!PestjsonArray.isNull(i)) {

                            PestEntity mpestEntity= new PestEntity(
                                    PestjsonArray.getJSONObject(i));


                            if((29<Double.valueOf(mpestEntity.getLatitude()))&&(Double.valueOf(mpestEntity.getLatitude())<35)
                                    &&(110<Double.valueOf(mpestEntity.getLongitude()))&&(Double.valueOf(mpestEntity.getLongitude())<120))
                            {
                                //System.out.println("aahhhhhh"+Double.valueOf(mtreeEntity.getLatitude()));
                                mPestEntities.add(mpestEntity);
                            }
                        }
                    }
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }


    public List<PestEntity> getPestEntities() {
        return mPestEntities;
    }

    public void setPestEntities(List<PestEntity> pestEntities) {
        mPestEntities = pestEntities;
    }
}
