一、前言
1. 背景描述
春节期间烟花爆竹禁燃禁放是保障公共安全、改善空气质量的重要举措,而禁燃政策落地的核心环节之一,是对县域范围内烟花爆竹销售点的精准盘点与动态监管。传统的人工排查方式存在效率低、数据更新不及时、空间位置可视化差等问题,难以满足县域精细化监管的需求。
地理信息系统(GIS)技术能够将空间位置与业务数据深度融合,而高德地图 API 提供了成熟的地理编码、POI 检索等能力,结合 Java 语言的跨平台、高稳定性特性,可快速搭建一套轻量化的县域烟花销售点盘点系统,实现销售点位置检索、数据整合、成果输出的全流程自动化,为禁燃监管决策提供数据支撑。
2. 聚焦新晃县
新晃侗族自治县隶属于湖南省怀化市,地处湘黔边界,县域内乡镇分布分散、地形复杂,烟花爆竹销售点多分布于乡镇集市、村级小卖部等场景,人工盘点耗时耗力且易出现遗漏。
本次实践以新晃县为研究对象,依托 Java 开发语言和高德地图 API,针对该县春节烟花禁燃后的销售点开展盘点工作,验证 GIS 技术在县域基层监管中的实用性,也为同类县域的烟花禁燃监管提供可复用的技术方案。
二、Java 实现高德检索
1. 接口定义
首先需在高德开放平台注册开发者账号,申请 Web 服务 API Key(注意区分「Web 服务」与「前端 JS」Key),本次核心使用高德的 POI 搜索接口(/v5/place/text),用于检索新晃县范围内的烟花爆竹销售点。
核心接口参数定义
package com.example.project.thridinterface;
import com.burukeyou.uniapi.http.annotation.HttpApi;
import com.burukeyou.uniapi.http.annotation.param.QueryPar;
import com.burukeyou.uniapi.http.annotation.request.GetHttpInterface;
import com.burukeyou.uniapi.http.core.response.HttpResponse;
@HttpApi(url = "https://restapi.amap.com/v5")
public interface AmapSearchService {
@GetHttpInterface("/place/text")
public HttpResponse<String> getSearch(
@QueryPar("keywords") String keywords,
@QueryPar("types") String types,
@QueryPar("region") String region,
@QueryPar("page_size") String page_size,
@QueryPar("page_num") String page_num,
@QueryPar("show_fields") String show_fields,
@QueryPar("key") String key
);
}
2. 数据获取
基于 UniHttp 实现 HTTP 请求,解析高德返回的 JSON 数据,提取销售点的核心信息(名称、地址、经纬度、联系方式)。
核心实现代码
package com.example.project.unihttp;
java.util.ArrayList;
java.util.List;
org.junit.Test;
org.junit.runner.RunWith;
org.springframework.beans.factory.annotation.Autowired;
org.springframework.boot.test.context.SpringBootTest;
org.springframework.test.context.junit4.SpringRunner;
com.google.gson.Gson;
com.yelang.common.utils.StringUtils;
com.yelang.common.utils.poi.ExcelUtil;
com.example.project.education.domain.amap.AmapPoi;
com.example.project.education.domain.amap.AmapSearchVO;
com.example.project.thridinterface.AmapSearchService;
{
;
AmapSearchService amapSearchService;
InterruptedException {
;
;
;
;
;
HttpResponse<String> result = ;
();
;
;
List<AmapPoi> amapPoiData = <>();
{
result = amapSearchService.getSearch(keywords, types, region, page_size, String.valueOf(scrapingIndex), show_fields, AMAP_CLIENT_AK);
System.out.println(result.getBodyResult());
(StringUtils.isNotEmpty(result.getBodyResult())) {
gson.fromJson(result.getBodyResult(), AmapSearchVO.class);
amapPoiData.addAll(searchVO.getPois());
dataCount = searchVO.getCount();
scrapingIndex++;
}
Thread.sleep();
} (dataCount > );
System.out.println( + scrapingIndex);
System.out.println(amapPoiData.size());
(amapPoiData.size() > ) {
ExcelUtil<AmapPoi> util = <>(AmapPoi.class);
util.exportExcel(amapPoiData, );
System.out.println();
}
}
}


