大牛分享爬取高德地圖poi數(shù)據(jù)實戰(zhàn)

高德地圖搜索poi的api介紹地址

當前想法是爬取目標區(qū)域(作者所在小縣城)的所有poi數(shù)據(jù),存到數(shù)據(jù)庫中作為原始數(shù)據(jù),然后供其它系統(tǒng)調用途茫,因為之前爬取過百度地圖的poi數(shù)據(jù)桌吃,所以這次工作就駕輕就熟了娜睛。

1哆键、首先注冊一個高德地圖的開發(fā)者賬號掘托,申請一個綁定Web服務的key,然后把剛注冊的開發(fā)者賬號認證一下: 申請賬號洼哎、key就不贅述了烫映,去高德地圖開發(fā)平臺很簡單就能完成了,將賬號認證是為了提高每日訪問高德地圖api接口的次數(shù)限制和并發(fā)請求噩峦。

2、根據(jù)上方api地址里面的介紹抽兆,總共分為4中搜索: 關鍵字搜索:通過用POI的關鍵字進行條件搜索识补,例如:肯德基、朝陽公園等辫红;同時支持設置POI類型搜索凭涂,例如:銀行 周邊搜索:在用戶傳入經緯度坐標點附近,在設定的范圍內贴妻,按照關鍵字或POI類型搜索切油; 多邊形搜索:在多邊形區(qū)域內進行搜索 ID查詢:通過POI ID,查詢某個POI詳情名惩,建議可同輸入提示API配合使用

我的目標是某個區(qū)域的所有poi澎胡,所以選擇的第三種:多邊形搜索

3、多邊形搜索最重要的參數(shù)就是polygon-》經緯度坐標對娩鹉,我在百度地圖坐標拾取系統(tǒng)拾取了我的目標區(qū)域的經緯度坐標對攻谁,如下圖:?

3步準備工作到這里就差不多結束了,在正式開始碼代碼之前先做個測試吧弯予,用瀏覽器直接訪問接口看看返回的數(shù)據(jù)(當然戚宦,高德的api接口有返回數(shù)據(jù)說明)

如上圖,這里比較重要的一個屬性是count锈嫩,根據(jù)api的介紹count是搜索方案數(shù)目(最大值為1000)受楼,所以說每次請求都會返回當前所搜所包含的poi個數(shù),而大于1000的poi是沒有辦法獲取到的呼寸。那么我如果想查詢某個區(qū)域的全部數(shù)據(jù)艳汽,可以將這個區(qū)域再劃分成更小的區(qū)域(顯然是個遞歸操作)的集合,然后把這幾個可以查到所有poi的區(qū)域的所有poi數(shù)據(jù)結合起來就是我最終需要的數(shù)據(jù)等舔∩Ь模可能口述不明朗,可以見下方草圖:

如果需要Python方面的入門知識可以點擊這個鏈接獲取入門資料


好慌植,可以開始擼代碼了:

因為甚牲,整個調用API的過程都離不開經緯度义郑,所以首先定義一個經緯度描述的類 `

//矩形塊的經緯度標識, 左上角的經緯度 和右下角的經緯度classRectangleCoordinate{/**

? ? * 矩形左上角經度

? ? */privatedoublex0;/**

? ? * 矩形左上角緯度

? ? */privatedoubley0;/**

? ? * 矩形右下角經度

? ? */privatedoublex1;/**

? ? * 矩形右下角緯度

? ? */privatedoubley1;publicRectangleCoordinate(doublex0,doubley0,doublex1,doubley1){this.x0 = x0;this.y0 = y0;this.x1 = x1;this.y1 = y1;? ? }/**

? ? * [@return](https://my.oschina.net/u/556800) 獲取矩形中心線的緯度

? ? */publicdoublegetAverageY(){return(y0 + y1) /2;? ? }/**

? ? * [@return](https://my.oschina.net/u/556800) 獲取矩形中心線的經度

? ? */publicdoublegetAverageX(){return(x0 + x1) /2;? ? }publicdoublegetX0(){returnx0;? ? }publicvoidsetX0(doublex0){this.x0 = x0;? ? }publicdoublegetY0(){returny0;? ? }publicvoidsetY0(doubley0){this.y0 = y0;? ? }publicdoublegetX1(){returnx1;? ? }publicvoidsetX1(doublex1){this.x1 = x1;? ? }publicdoublegetY1(){returny1;? ? }publicvoidsetY1(doubley1){this.y1 = y1;? ? }? ? [@Override](https://my.oschina.net/u/1162528)publicStringtoString(){returnx0 +","+ y0 +"|"+ x1 +","+ y1;? ? }}`

然后需要一個調用api丈钙,獲取返回數(shù)據(jù)的方法非驮,這個方法參數(shù)就是矩形塊,當然還需要一個頁數(shù)雏赦,即當前方法獲取的是某個矩形區(qū)域的第X頁的數(shù)據(jù)(每頁上線25個poi劫笙,默認20個poi)

/**? ? *@return獲取矩形塊的poi數(shù)據(jù)? ? */privateJSONObjectgetSearchResult(RectangleCoordinate coordinate,intpage){? ? ? ? RestTemplate restTemplate =newRestTemplate();? ? ? ? String url = getRequestGaodeUrl(coordinate,page);? ? ? ? String result = restTemplate.getForObject(url, String.class);try{try{? ? ? ? ? ? ? ? Thread.sleep(50);? ? ? ? ? ? }catch(InterruptedException e) {? ? ? ? ? ? ? ? e.printStackTrace();? ? ? ? ? ? }returnJSONObject.parseObject(result);? ? ? ? }catch(Exception e) {? ? ? ? ? ? logger.error("an error occurred when getting response of gaode map data for coordinate:[{}]", coordinate.toString());? ? ? ? }returnnull;? ? }

當然,上方已經說過星岗,如果矩形塊返回數(shù)據(jù)count=1000填大,就說明當前矩形塊需要分割,我的想法比較簡單俏橘,將矩形塊按照上方草圖允华,在水平中心和垂直分心分割,1個矩形塊就分割成4個小矩形塊了寥掐,方法如下:

/**? ? *@return將矩形4等分成小矩形 然后返回4個 小矩形的經緯度集合? ? */privateListgetSplitRectangleList(RectangleCoordinate coordinate){? ? ? ? List splitRectangleList =newLinkedList<>();? ? ? ? splitRectangleList.add(newRectangleCoordinate(coordinate.getX0(), coordinate.getY0(), coordinate.getAverageX(), coordinate.getAverageY()));? ? ? ? splitRectangleList.add(newRectangleCoordinate(coordinate.getAverageX(), coordinate.getY0(), coordinate.getX1(), coordinate.getAverageY()));? ? ? ? splitRectangleList.add(newRectangleCoordinate(coordinate.getX0(), coordinate.getAverageY(), coordinate.getAverageX(), coordinate.getY1()));? ? ? ? splitRectangleList.add(newRectangleCoordinate(coordinate.getAverageX(), coordinate.getAverageY(), coordinate.getX1(), coordinate.getY1()));returnsplitRectangleList;? ? }

目前靴寂,可以獲取到矩形區(qū)域經緯度對的集合了,也有獲取api數(shù)據(jù)的方法了召耘,然后就是遍歷頁數(shù)獲取數(shù)據(jù)百炬,自定義操作數(shù)據(jù)。 當某次分頁請求返回的poi個數(shù)小于每頁最大個數(shù)的時候就認為當前區(qū)域poi已經完全請求到了污它。

privatevoidstartAnaMainGaode(RectangleCoordinate coordinate)throwsAnalysisException{//當前爬取的數(shù)據(jù)的頁數(shù)索引intpage_num =0;//當前爬取內容是否是最后一頁booleanisLastPage =false;? ? ? ? JSONObject searchResult;? ? ? ? JSONArray datas =null;? ? ? ? logger.info("ready to analysis coordinate:[{}]", coordinate.toString());while(!isLastPage) {? ? ? ? ? ? logger.info("is going to get data for page_"+ page_num);try{? ? ? ? ? ? ? ? searchResult = getSearchResult(coordinate, page_num);? ? ? ? ? ? ? ? datas = searchResult.getJSONArray("pois");? ? ? ? ? ? }catch(Exception e) {? ? ? ? ? ? ? ? logger.error("an error occurred when getting response of gaode map data for coordinate:[{}]", coordinate.toString());? ? ? ? ? ? }if(datas !=null&& datas.size() <20) {? ? ? ? ? ? ? ? isLastPage =true;? ? ? ? ? ? ? ? logger.info("get result counts is [{}], now page index is [{}]", datas.size(), page_num);? ? ? ? ? ? }? ? ? ? ? ? saveIntoDbGaode(datas);? ? ? ? ? ? page_num++;? ? ? ? }? ? }

privatevoidsaveIntoDbGaode(JSONArray result){? ? JSONObject resultItem;for(inti =0; i < result.size(); i++) {? ? ? ? resultItem = result.getJSONObject(i);try{? ? ? ? ? ? results.add(getInsertUnitObject(resultItem));? ? ? ? }catch(Exception e) {? ? ? ? ? ? logger.error("生成數(shù)據(jù)時異常剖踊,e: {}", e.getMessage());? ? ? ? ? ? e.printStackTrace();? ? ? ? }? ? }if(results.size() > BATCHINSERTLIMIT || ISLAST) {? ? ? ? logger.info("is ready to batch insert into unit, total count is {}", results.size());try{? ? ? ? ? ? dao.batchAddUnitGaode(results);? ? ? ? }catch(Exception e) {? ? ? ? ? ? logger.error("更新數(shù)據(jù)庫異常,e: {}", e.getMessage());? ? ? ? }? ? ? ? results =newJSONArray();? ? }}`

到此轨蛤,基本方法都介紹過了蜜宪,全部代碼如下(因為都是簡單方法和邏輯,不明白的留言交流)

//請求入口 publicvoidGaodePoiSearch(){//徐水區(qū) final RectangleCoordinate searchAreaCoordinate = new RectangleCoordinate(115.521773, 39.106335, 115.801182, 38.943988);? ? //保定市//final RectangleCoordinate searchAreaCoordinate = new RectangleCoordinate(114.332719,39.574064, 116.588688,38.179144);List validCoordinate = getValidCoordinate(searchAreaCoordinate);? ? logger.info("get all valid coordinate,size is [{}]", validCoordinate.size());/**

? ? * 獲取到所有的小方塊之后可以做一些處理祥山, 比如存儲到某個地方圃验,以防發(fā)生異常,方便后面重新遍歷缝呕,我這里暫未做處理

? ? */validCoordinate.forEach(coor -> {try{? ? ? ? ? ? startAnaMainGaode(coor);? ? ? ? }catch(AnalysisException e) {? ? ? ? ? ? e.printStackTrace();? ? ? ? }? ? });? ? ISLAST =true;? ? saveIntoDbGaode(newJSONArray());}/** * [@return](https://my.oschina.net/u/556800) 獲取矩形塊中 符合 調用api的 小矩形塊的集合 * 因為高德地圖某個矩形塊只能獲取前1000條澳窑,所以要將矩形塊分割成可以獲取到全部數(shù)據(jù)的矩形塊 * 如果當前矩形塊請求數(shù)據(jù)返回的count<1000 即為符合條件的,否則將矩形塊4等分 然后遞歸 */privateListgetValidCoordinate(RectangleCoordinate coordinate){? ? List validCoordinate =newLinkedList<>();? ? JSONObject searchResult = getSearchResult(coordinate,0);if(searchResult.getIntValue("count") >=1000) {? ? ? ? List splitRectangleList = getSplitRectangleList(coordinate);? ? ? ? splitRectangleList.forEach(coor -> validCoordinate.addAll(getValidCoordinate(coor)));? ? }else{? ? ? ? logger.info("add a valid coordinate [{}]", coordinate.toString());? ? ? ? validCoordinate.add(coordinate);? ? }returnvalidCoordinate;}/** * [@return](https://my.oschina.net/u/556800) 將矩形4等分成小矩形 然后返回4個 小矩形的經緯度集合 */privateListgetSplitRectangleList(RectangleCoordinate coordinate){? ? List splitRectangleList =newLinkedList<>();? ? splitRectangleList.add(newRectangleCoordinate(coordinate.getX0(), coordinate.getY0(), coordinate.getAverageX(), coordinate.getAverageY()));? ? splitRectangleList.add(newRectangleCoordinate(coordinate.getAverageX(), coordinate.getY0(), coordinate.getX1(), coordinate.getAverageY()));? ? splitRectangleList.add(newRectangleCoordinate(coordinate.getX0(), coordinate.getAverageY(), coordinate.getAverageX(), coordinate.getY1()));? ? splitRectangleList.add(newRectangleCoordinate(coordinate.getAverageX(), coordinate.getAverageY(), coordinate.getX1(), coordinate.getY1()));returnsplitRectangleList;}/** *@return獲取矩形塊的poi數(shù)據(jù) */privateJSONObjectgetSearchResult(RectangleCoordinate coordinate,intpage){? ? RestTemplate restTemplate =newRestTemplate();? ? String url = getRequestGaodeUrl(coordinate,page);? ? String result = restTemplate.getForObject(url, String.class);try{try{? ? ? ? ? ? Thread.sleep(50);? ? ? ? }catch(InterruptedException e) {? ? ? ? ? ? e.printStackTrace();? ? ? ? }returnJSONObject.parseObject(result);? ? }catch(Exception e) {? ? ? ? logger.error("an error occurred when getting response of gaode map data for coordinate:[{}]", coordinate.toString());? ? }returnnull;}privatevoidstartAnaMainGaode(RectangleCoordinate coordinate)throwsAnalysisException{//當前爬取的數(shù)據(jù)的頁數(shù)索引intpage_num =0;//當前爬取內容是否是最后一頁booleanisLastPage =false;? ? JSONObject searchResult;? ? JSONArray datas =null;? ? logger.info("ready to analysis coordinate:[{}]", coordinate.toString());while(!isLastPage) {? ? ? ? logger.info("is going to get data for page_"+ page_num);try{? ? ? ? ? ? searchResult = getSearchResult(coordinate, page_num);? ? ? ? ? ? datas = searchResult.getJSONArray("pois");? ? ? ? }catch(Exception e) {? ? ? ? ? ? logger.error("an error occurred when getting response of gaode map data for coordinate:[{}]", coordinate.toString());? ? ? ? }if(datas !=null&& datas.size() <20) {? ? ? ? ? ? isLastPage =true;? ? ? ? ? ? logger.info("get result counts is [{}], now page index is [{}]", datas.size(), page_num);? ? ? ? }? ? ? ? saveIntoDbGaode(datas);? ? ? ? page_num++;? ? }}privatevoidsaveIntoDbGaode(JSONArray result){? ? JSONObject resultItem;for(inti =0; i < result.size(); i++) {? ? ? ? resultItem = result.getJSONObject(i);try{? ? ? ? ? ? results.add(getInsertUnitObject(resultItem));? ? ? ? }catch(Exception e) {? ? ? ? ? ? logger.error("生成數(shù)據(jù)時異常供常,e: {}", e.getMessage());? ? ? ? ? ? e.printStackTrace();? ? ? ? }? ? }if(results.size() > BATCHINSERTLIMIT || ISLAST) {? ? ? ? logger.info("is ready to batch insert into unit, total count is {}", results.size());try{? ? ? ? ? ? dao.batchAddUnitGaode(results);? ? ? ? }catch(Exception e) {? ? ? ? ? ? logger.error("更新數(shù)據(jù)庫異常摊聋,e: {}", e.getMessage());? ? ? ? }? ? ? ? results =newJSONArray();? ? }}privateJSONObjectgetInsertUnitObject(JSONObject resultItem){? ? JSONObject unitDataObject =newJSONObject();? ? unitDataObject.put("uid", resultItem.getString("id"));? ? unitDataObject.put("name", resultItem.getString("name"));? ? unitDataObject.put("type", resultItem.getString("type"));? ? unitDataObject.put("tag", resultItem.getString("type"));? ? unitDataObject.put("address", resultItem.getString("address"));? ? unitDataObject.put("province", resultItem.getString("pname"));? ? unitDataObject.put("city", resultItem.getString("cityname"));? ? unitDataObject.put("area", resultItem.getString("adname"));? ? String tel = resultItem.getString("tel");if(tel !=null&& !"[]".equals(tel)) {? ? ? ? unitDataObject.put("telephone", tel);? ? }try{? ? ? ? JSONArray url = resultItem.getJSONArray("website");if(url !=null&& url.size() >0) {? ? ? ? ? ? unitDataObject.put("detail_url", url.getString(0));? ? ? ? }? ? }catch(Exception e) {? ? ? ? unitDataObject.put("detail_url", resultItem.getString("website"));? ? }? ? JSONArray photos = resultItem.getJSONArray("photos");if(photos !=null&& photos.size() >0) {? ? ? ? StringBuilder images =newStringBuilder();for(intj =0; j < photos.size(); j++) {? ? ? ? ? ? images.append(j ==0?"":";").append(photos.getJSONObject(j).getString("url"));? ? ? ? }? ? ? ? unitDataObject.put("images", images.toString());? ? }? ? String entr_location = resultItem.getString("location");if(StringUtils.isEmpty(entr_location)) {? ? ? ? entr_location = resultItem.getString("entr_location");? ? }if(!StringUtils.isEmpty(entr_location)) {? ? ? ? unitDataObject.put("lng", entr_location.split(",")[0]);? ? ? ? unitDataObject.put("lat", entr_location.split(",")[1]);? ? }returnunitDataObject;}privateStringgetRequestGaodeUrl(RectangleCoordinate coordinate,intpage){return"https://restapi.amap.com/v3/place/polygon?"+"key=xxxxxxxxxxxxxxxxxxxxxxx&polygon="+ coordinate.toString() +"&page="+ page +"&types=010000|"+"010100|010101|010102|010103|010104|010105|010107|010108|010109|010110|010111|010112|010200|010300|010400|"+"010401|010500|010600|010700|010800|010900|010901|011000|011100|020000|020100|020101|020102|020103|020104|"+"020105|020106|020200|020201|020202|020203|020300|020301|020400|020401|020402|020403|020404|020405|020406|"+"020407|020408|020600|020601|020602|020700|020701|020702|020703|020800|020900|020904|020905|021000|021001|"+"021002|021003|021004|021100|021200|021201|021202|021203|021300|021301|021400|021401|021500|021501|021600|"+"021601|021602|021700|021701|021702|021800|021802|021803|021804|021900|022000|022100|022200|022300|022301|"+"022400|022500|022501|022502|022600|022700|022800|022900|023000|023100|023200|023300|023301|023400|023500|"+"025000|025100|025200|025300|025400|025500|025600|025700|025800|025900|026000|026100|026200|026300|029900|"+"030000|030100|030200|030201|030202|030203|030204|030205|030206|030300|030301|030302|030303|030400|030401|"+"030500|030501|030502|030503|030504|030505|030506|030507|030508|030700|030701|030702|030800|030801|030802|"+"030803|030900|031000|031004|031005|031100|031101|031102|031103|031104|031200|031300|031301|031302|031303|"+"031400|031401|031500|031501|031600|031601|031700|031701|031702|031800|031801|031802|031900|031902|031903|"+"031904|032000|032100|032200|032300|032400|032401|032500|032600|032601|032602|032700|032800|032900|033000|"+"033100|033200|033300|033400|033401|033500|033600|035000|035100|035200|035300|035400|035500|035600|035700|"+"035800|035900|036000|036100|036200|036300|039900|040000|040100|040101|040200|040201|050000|050100|050101|"+"050102|050103|050104|050105|050106|050107|050108|050109|050110|050111|050112|050113|050114|050115|050116|"+"050117|050118|050119|050120|050121|050122|050123|050200|050201|050202|050203|050204|050205|050206|050207|"+"050208|050209|050210|050211|050212|050213|050214|050215|050216|050217|050300|050301|050302|050303|050304|"+"050305|050306|050307|050308|050309|050310|050311|050400|050500|050501|050502|050503|050504|050600|050700|"+"050800|050900|060000|060100|060101|060102|060103|060200|060201|060202|060300|060301|060302|060303|060304|"+"060305|060306|060307|060308|060400|060401|060402|060403|060404|060405|060406|060407|060408|060409|060411|"+"060413|060414|060415|060500|060501|060502|060600|060601|060602|060603|060604|060605|060606|060700|060701|"+"060702|060703|060704|060705|060706|060800|060900|060901|060902|060903|060904|060905|060906|060907|061000|"+"061001|061100|061101|061102|061103|061104|061200|061201|061202|061203|061204|061205|061206|061207|061208|"+"061209|061210|061211|061212|061213|061214|061300|061301|061302|061400|061401|070000|070100|070200|070201|"+"070202|070203|070300|070301|070302|070303|070304|070305|070306|070400|070401|070500|070501|070600|070601|"+"070603|070604|070605|070606|070607|070608|070609|070610|070700|070701|070702|070703|070704|070705|070706|"+"070800|070900|071000|071100|071200|071300|071400|071500|071600|071700|071800|071801|071900|071901|071902|"+"071903|072000|072001|080000|080100|080101|080102|080103|080104|080105|080106|080107|080108|080109|080110|"+"080111|080112|080113|080114|080115|080116|080117|080118|080119|080200|080201|080202|080300|080301|080302|"+"080303|080304|080305|080306|080307|080308|080400|080401|080402|080500|080501|080502|080503|080504|080505|"+"080600|080601|080602|080603|090000|090100|090101|090102|090200|090201|090202|090203|090204|090205|090206|"+"090207|090208|090209|090210|090211|090300|090400|090500|090600|090601|090602|090700|090701|090702|100000|"+"100100|100101|100102|100103|100104|100105|100200|100201|110000|110100|110101|110102|110103|110104|110105|"+"110106|110200|110201|110202|110203|110204|110205|110206|110207|110208|110209|120000|120100|120200|120201|"+"120202|120203|120300|120301|120302|120303|120304|130000|130100|130101|130102|130103|130104|130105|130106|"+"130107|130200|130201|130202|130300|130400|130401|130402|130403|130404|130405|130406|130407|130408|130409|"+"130500|130501|130502|130503|130504|130505|130506|130600|130601|130602|130603|130604|130605|130606|130700|"+"130701|130702|130703|140000|140100|140101|140102|140200|140201|140300|140400|140500|140600|140700|140800|"+"140900|141000|141100|141101|141102|141103|141104|141105|141200|141201|141202|141203|141204|141205|141206|"+"141207|141300|141400|141500|150000|150100|150101|150102|150104|150105|150106|150107|150200|150201|150202|"+"150203|150204|150205|150206|150207|150208|150209|150210|150300|150301|150302|150303|150304|150400|150500|"+"150501|150600|150700|150701|150702|150703|150800|150900|150903|150904|150905|150906|150907|150908|150909|"+"151000|151100|151200|151300|160000|160100|160101|160102|160103|160104|160105|160106|160107|160108|160109|"+"160110|160111|160112|160113|160114|160115|160117|160118|160119|160120|160121|160122|160123|160124|160125|"+"160126|160127|160128|160129|160130|160131|160132|160133|160134|160135|160136|160137|160138|160139|160140|"+"160141|160142|160143|160144|160145|160146|160147|160148|160149|160150|160151|160152|160200|160300|160301|"+"160302|160303|160304|160305|160306|160307|160308|160309|160310|160311|160312|160314|160315|160316|160317|"+"160318|160319|160320|160321|160322|160323|160324|160325|160326|160327|160328|160329|160330|160331|160332|"+"160333|160334|160335|160336|160337|160338|160339|160340|160341|160342|160343|160344|160345|160346|160347|"+"160348|160349|160400|160401|160402|160403|160404|160405|160406|160407|160408|160500|160501|160600|170000|"+"170100|170200|170201|170202|170203|170204|170205|170206|170207|170208|170209|170300|170400|170401|170402|"+"170403|170404|170405|170406|170407|170408|180000|180100|180101|180102|180103|180104|180200|180201|180202|"+"180203|180300|180301|180302|180400|180500|190000|190100|190101|190102|190103|190104|190105|190106|190107|"+"190108|190109|190200|190201|190202|190203|190204|190205|190300|190301|190302|190303|190304|190305|190306|"+"190307|190308|190309|190310|190311|190400|190401|190402|190403|190500|190600|190700|200000|200100|200200|"+"200300|200301|200302|200303|200304|200400|220000|220100|220101|220102|220103|220104|220105|220106|220107|"+"220200|220201|220202|220203|220204|220205|970000|990000|991000|991001|991400|991401|991500&extensions=all";}/**

* 矩形塊的經緯度標識, 左上角的經緯度 和右下角的經緯度

*/classRectangleCoordinate{/**

? ? * 矩形左上角經度

? ? */privatedoublex0;/**

? ? * 矩形左上角緯度

? ? */privatedoubley0;/**

? ? * 矩形右下角經度

? ? */privatedoublex1;/**

? ? * 矩形右下角緯度

? ? */privatedoubley1;publicRectangleCoordinate(doublex0,doubley0,doublex1,doubley1){this.x0 = x0;this.y0 = y0;this.x1 = x1;this.y1 = y1;? ? }/**? ? *@return獲取矩形中心線的緯度? ? */publicdoublegetAverageY(){return(y0 + y1) /2;? ? }/**? ? *@return獲取矩形中心線的經度? ? */publicdoublegetAverageX(){return(x0 + x1) /2;? ? }publicdoublegetX0(){returnx0;? ? }publicvoidsetX0(doublex0){this.x0 = x0;? ? }publicdoublegetY0(){returny0;? ? }publicvoidsetY0(doubley0){this.y0 = y0;? ? }publicdoublegetX1(){returnx1;? ? }publicvoidsetX1(doublex1){this.x1 = x1;? ? }publicdoublegetY1(){returny1;? ? }publicvoidsetY1(doubley1){this.y1 = y1;? ? }@OverridepublicStringtoString(){returnx0 +","+ y0 +"|"+ x1 +","+ y1;? ? }}`

更新(2018-09-20):

1栈暇、時間問題麻裁,當前50ms請求一次api接口,跑完小縣城的數(shù)據(jù)(幾萬條)大概需要十分鐘左右吧,把整個市區(qū)主要數(shù)據(jù)跑完斷斷續(xù)續(xù)的用了一天吧煎源,最后跑了近27W數(shù)據(jù)

原文鏈接:https://my.oschina.net/u/1417838/blog/2054570

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末色迂,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子手销,更是在濱河造成了極大的恐慌歇僧,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,402評論 6 499
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件锋拖,死亡現(xiàn)場離奇詭異诈悍,居然都是意外死亡,警方通過查閱死者的電腦和手機兽埃,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,377評論 3 392
  • 文/潘曉璐 我一進店門侥钳,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人讲仰,你說我怎么就攤上這事慕趴。” “怎么了鄙陡?”我有些...
    開封第一講書人閱讀 162,483評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長躏啰。 經常有香客問我趁矾,道長,這世上最難降的妖魔是什么给僵? 我笑而不...
    開封第一講書人閱讀 58,165評論 1 292
  • 正文 為了忘掉前任毫捣,我火速辦了婚禮,結果婚禮上帝际,老公的妹妹穿的比我還像新娘蔓同。我一直安慰自己,他們只是感情好蹲诀,可當我...
    茶點故事閱讀 67,176評論 6 388
  • 文/花漫 我一把揭開白布斑粱。 她就那樣靜靜地躺著,像睡著了一般脯爪。 火紅的嫁衣襯著肌膚如雪则北。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,146評論 1 297
  • 那天痕慢,我揣著相機與錄音尚揣,去河邊找鬼。 笑死掖举,一個胖子當著我的面吹牛快骗,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 40,032評論 3 417
  • 文/蒼蘭香墨 我猛地睜開眼方篮,長吁一口氣:“原來是場噩夢啊……” “哼名秀!你這毒婦竟也來了?” 一聲冷哼從身側響起恭取,我...
    開封第一講書人閱讀 38,896評論 0 274
  • 序言:老撾萬榮一對情侶失蹤泰偿,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后蜈垮,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體耗跛,經...
    沈念sama閱讀 45,311評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,536評論 2 332
  • 正文 我和宋清朗相戀三年攒发,在試婚紗的時候發(fā)現(xiàn)自己被綠了调塌。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,696評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡惠猿,死狀恐怖羔砾,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情偶妖,我是刑警寧澤姜凄,帶...
    沈念sama閱讀 35,413評論 5 343
  • 正文 年R本政府宣布,位于F島的核電站趾访,受9級特大地震影響态秧,放射性物質發(fā)生泄漏。R本人自食惡果不足惜扼鞋,卻給世界環(huán)境...
    茶點故事閱讀 41,008評論 3 325
  • 文/蒙蒙 一申鱼、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧云头,春花似錦捐友、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,659評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至竿痰,卻和暖如春脆粥,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背影涉。 一陣腳步聲響...
    開封第一講書人閱讀 32,815評論 1 269
  • 我被黑心中介騙來泰國打工变隔, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人蟹倾。 一個月前我還...
    沈念sama閱讀 47,698評論 2 368
  • 正文 我出身青樓匣缘,卻偏偏與公主長得像猖闪,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子肌厨,可洞房花燭夜當晚...
    茶點故事閱讀 44,592評論 2 353

推薦閱讀更多精彩內容