Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Hypo
EE-Codes-of-SCNU
提交
33720705
E
EE-Codes-of-SCNU
项目概览
Hypo
/
EE-Codes-of-SCNU
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
EE-Codes-of-SCNU
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
33720705
编写于
1月 19, 2020
作者:
E
Eddie-He-090
提交者:
GitHub
1月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add files via upload
上级
f470cf37
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
1321 addition
and
0 deletion
+1321
-0
Java_2019-2020/期末大作业/src.com.company/ALiAround.java
Java_2019-2020/期末大作业/src.com.company/ALiAround.java
+51
-0
Java_2019-2020/期末大作业/src.com.company/ALiBicycling.java
Java_2019-2020/期末大作业/src.com.company/ALiBicycling.java
+46
-0
Java_2019-2020/期末大作业/src.com.company/ALiDriving.java
Java_2019-2020/期末大作业/src.com.company/ALiDriving.java
+56
-0
Java_2019-2020/期末大作业/src.com.company/ALiGeocode.java
Java_2019-2020/期末大作业/src.com.company/ALiGeocode.java
+51
-0
Java_2019-2020/期末大作业/src.com.company/ALiIP.java
Java_2019-2020/期末大作业/src.com.company/ALiIP.java
+34
-0
Java_2019-2020/期末大作业/src.com.company/ALiIntegrated.java
Java_2019-2020/期末大作业/src.com.company/ALiIntegrated.java
+52
-0
Java_2019-2020/期末大作业/src.com.company/ALiMap.java
Java_2019-2020/期末大作业/src.com.company/ALiMap.java
+263
-0
Java_2019-2020/期末大作业/src.com.company/ALiText.java
Java_2019-2020/期末大作业/src.com.company/ALiText.java
+55
-0
Java_2019-2020/期末大作业/src.com.company/ALiWeatherInfo.java
Java_2019-2020/期末大作业/src.com.company/ALiWeatherInfo.java
+126
-0
Java_2019-2020/期末大作业/src.com.company/BDIP.java
Java_2019-2020/期末大作业/src.com.company/BDIP.java
+52
-0
Java_2019-2020/期末大作业/src.com.company/BDMap.java
Java_2019-2020/期末大作业/src.com.company/BDMap.java
+185
-0
Java_2019-2020/期末大作业/src.com.company/BDPathPlanning.java
Java_2019-2020/期末大作业/src.com.company/BDPathPlanning.java
+180
-0
Java_2019-2020/期末大作业/src.com.company/BDSearch.java
Java_2019-2020/期末大作业/src.com.company/BDSearch.java
+64
-0
Java_2019-2020/期末大作业/src.com.company/BDgeocode.java
Java_2019-2020/期末大作业/src.com.company/BDgeocode.java
+58
-0
Java_2019-2020/期末大作业/src.com.company/MapMain.java
Java_2019-2020/期末大作业/src.com.company/MapMain.java
+48
-0
未找到文件。
Java_2019-2020/期末大作业/src.com.company/ALiAround.java
0 → 100644
浏览文件 @
33720705
package
Map
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
public
class
ALiAround
{
public
String
location
;
public
String
keywords
;
public
String
name
;
public
String
type
;
public
String
address
;
public
String
pname
;
public
String
cityname
;
public
String
adname
;
public
void
Do_around
()
throws
IOException
{
StringBuilder
json
=
new
StringBuilder
();
URL
name
=
new
URL
(
"https://restapi.amap.com/v3/place/around?key=b3524cc502a4fc39c0d2a2e5cb97b516&location"
+
"="
+
this
.
location
+
"&keywords="
+
this
.
keywords
+
"&types=&radius"
+
"=&offset=&page"
+
"=&extensions=all"
);
// URL name = new URL("https://restapi.amap.com/v3/direction/transit/integrated" +
// "?key=b3524cc502a4fc39c0d2a2e5cb97b516&origin=116.481028,39" +
// ".989643&destination=116.434446,39" +
// ".90816&city=北京&cityd=北京&strategy=0&nightflag=0");
URLConnection
connection
=
name
.
openConnection
();
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
str
;
while
((
str
=
in
.
readLine
())
!=
null
)
{
json
.
append
(
str
);
}
in
.
close
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json
));
JSONArray
pois
=
jsonObject
.
getJSONArray
(
"pois"
);
JSONObject
temp0
=
pois
.
getJSONObject
(
Integer
.
parseInt
(
"0"
));
this
.
name
=
temp0
.
get
(
"name"
).
toString
();
this
.
type
=
temp0
.
get
(
"type"
).
toString
();
this
.
address
=
temp0
.
get
(
"address"
).
toString
();
this
.
pname
=
temp0
.
get
(
"pname"
).
toString
();
this
.
cityname
=
temp0
.
get
(
"cityname"
).
toString
();
this
.
adname
=
temp0
.
get
(
"adname"
).
toString
();
}
}
Java_2019-2020/期末大作业/src.com.company/ALiBicycling.java
0 → 100644
浏览文件 @
33720705
package
Map
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
public
class
ALiBicycling
{
public
String
origin
;
public
String
destination
;
public
String
distance
;
public
String
duration
;
public
void
Do_bicycling
()
throws
IOException
{
StringBuilder
json
=
new
StringBuilder
();
URL
name
=
new
URL
(
"https://restapi.amap"
+
".com/v4/direction/bicycling?origin="
+
this
.
origin
+
"&destination="
+
this
.
destination
+
"&key=b3524cc502a4fc39c0d2a2e5cb97b516"
);
// URL name = new URL("https://restapi.amap
// .com/v3/direction/transit/integrated" +
// "?key=b3524cc502a4fc39c0d2a2e5cb97b516&origin=116.481028,39" +
// ".989643&destination=116.434446,39" +
// ".90816&city=北京&cityd=北京&strategy=0&nightflag=0");
URLConnection
connection
=
name
.
openConnection
();
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
str
;
while
((
str
=
in
.
readLine
())
!=
null
)
{
json
.
append
(
str
);
}
in
.
close
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json
));
JSONObject
data
=
(
JSONObject
)
jsonObject
.
get
(
"data"
);
JSONArray
paths
=
data
.
getJSONArray
(
"paths"
);
JSONObject
temp0
=
paths
.
getJSONObject
(
Integer
.
parseInt
(
"0"
));
this
.
distance
=
temp0
.
get
(
"distance"
).
toString
();
this
.
duration
=
temp0
.
get
(
"duration"
).
toString
();
}
}
Java_2019-2020/期末大作业/src.com.company/ALiDriving.java
0 → 100644
浏览文件 @
33720705
package
Map
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
public
class
ALiDriving
{
public
String
origin
;
public
String
destination
;
public
String
distance
;
public
String
duration
;
public
String
strategy
;
public
String
tolls
;
public
String
traffic_lights
;
public
void
Do_driving
()
throws
IOException
{
StringBuilder
json
=
new
StringBuilder
();
URL
name
=
new
URL
(
"https://restapi.amap"
+
".com/v3/direction/driving?key"
+
"=b3524cc502a4fc39c0d2a2e5cb97b516&origin="
+
this
.
origin
+
"&destination="
+
this
.
destination
+
"&originid"
+
"=&destinationid"
+
"=&extensions"
+
"=base&strategy=0"
+
"&waypoints=&avoidpolygons=&avoidroad="
);
// URL name = new URL("https://restapi.amap
// .com/v3/direction/transit/integrated" +
// "?key=b3524cc502a4fc39c0d2a2e5cb97b516&origin=116.481028,39" +
// ".989643&destination=116.434446,39" +
// ".90816&city=北京&cityd=北京&strategy=0&nightflag=0");
URLConnection
connection
=
name
.
openConnection
();
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
str
;
while
((
str
=
in
.
readLine
())
!=
null
)
{
json
.
append
(
str
);
}
in
.
close
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json
));
JSONObject
route
=
(
JSONObject
)
jsonObject
.
get
(
"route"
);
JSONArray
paths
=
route
.
getJSONArray
(
"paths"
);
JSONObject
temp0
=
paths
.
getJSONObject
(
Integer
.
parseInt
(
"0"
));
this
.
distance
=
temp0
.
get
(
"distance"
).
toString
();
this
.
duration
=
temp0
.
get
(
"duration"
).
toString
();
this
.
strategy
=
temp0
.
get
(
"strategy"
).
toString
();
this
.
tolls
=
temp0
.
get
(
"tolls"
).
toString
();
this
.
traffic_lights
=
temp0
.
get
(
"traffic_lights"
).
toString
();
}
}
Java_2019-2020/期末大作业/src.com.company/ALiGeocode.java
0 → 100644
浏览文件 @
33720705
package
Map
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.util.Scanner
;
public
class
ALiGeocode
{
public
int
return0
;
public
String
address
;
public
String
formatted_address
;
public
String
adcode
;
public
String
citycode
;
public
String
location
;
public
void
Do_geocode
()
throws
IOException
{
StringBuilder
json
=
new
StringBuilder
();
Scanner
scanner
=
new
Scanner
(
System
.
in
);
this
.
address
=
scanner
.
nextLine
();
if
(
this
.
address
.
equals
(
"0"
))
{
this
.
return0
=
1
;
return
;
}
System
.
out
.
print
(
"处理中\n"
);
URL
name
=
new
URL
(
"https://restapi.amap"
+
".com/v3/geocode/geo?key=b3524cc502a4fc39c0d2a2e5cb97b516"
+
"&address="
+
this
.
address
+
"&city="
);
URLConnection
connection
=
name
.
openConnection
();
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
str
;
while
((
str
=
in
.
readLine
())
!=
null
)
{
json
.
append
(
str
);
}
in
.
close
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json
));
JSONArray
geocodes
=
jsonObject
.
getJSONArray
(
"geocodes"
);
// System.out.println(geocodes); //用于测试是否接成功转换geocodes
JSONObject
temp0
=
(
JSONObject
)
geocodes
.
get
(
Integer
.
parseInt
(
"0"
));
this
.
formatted_address
=
temp0
.
get
(
"formatted_address"
).
toString
();
this
.
adcode
=
temp0
.
get
(
"adcode"
).
toString
();
this
.
citycode
=
temp0
.
get
(
"citycode"
).
toString
();
this
.
location
=
temp0
.
get
(
"location"
).
toString
();
}
}
Java_2019-2020/期末大作业/src.com.company/ALiIP.java
0 → 100644
浏览文件 @
33720705
package
Map
;
import
java.net.URL
;
import
java.io.*
;
import
java.net.URLConnection
;
import
com.alibaba.fastjson.JSONObject
;
public
class
ALiIP
{
public
String
ip
;
public
String
province
;
public
String
city
;
public
void
Do_ip
()
throws
IOException
{
StringBuilder
json
=
new
StringBuilder
();
URL
name
=
new
URL
(
"https://restapi.amap.com/v3/ip?ip="
+
this
.
ip
+
"&output=json&key=b3524cc502a4fc39c0d2a2e5cb97b516"
);
// URL name = new URL("https://restapi.amap.com/v3/ip?ip=114.247.50" +
// ".2&output=json&key=b3524cc502a4fc39c0d2a2e5cb97b516");
URLConnection
connection
=
name
.
openConnection
();
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
str
;
while
((
str
=
in
.
readLine
())
!=
null
)
{
json
.
append
(
str
);
}
in
.
close
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json
));
this
.
province
=
jsonObject
.
getString
(
"province"
);
this
.
city
=
jsonObject
.
getString
(
"city"
);
}
}
Java_2019-2020/期末大作业/src.com.company/ALiIntegrated.java
0 → 100644
浏览文件 @
33720705
package
Map
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
public
class
ALiIntegrated
{
public
String
city
;
public
String
cityd
;
public
String
origin
;
public
String
destination
;
public
String
distance
;
public
String
taxi_cost
;
public
String
cost
;
public
String
duration
;
public
void
Do_integrated
()
throws
IOException
{
StringBuilder
json
=
new
StringBuilder
();
URL
name
=
new
URL
(
"https://restapi.amap.com/v3/direction/transit/integrated"
+
"?key=b3524cc502a4fc39c0d2a2e5cb97b516&origin="
+
this
.
origin
+
"&destination"
+
"="
+
this
.
destination
+
"&city="
+
this
.
city
+
"&cityd="
+
this
.
cityd
+
"&strategy=0"
+
"&nightflag=0"
);
// URL name = new URL("https://restapi.amap.com/v3/direction/transit/integrated" +
// "?key=b3524cc502a4fc39c0d2a2e5cb97b516&origin=116.481028,39" +
// ".989643&destination=116.434446,39" +
// ".90816&city=北京&cityd=北京&strategy=0&nightflag=0");
URLConnection
connection
=
name
.
openConnection
();
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
str
;
while
((
str
=
in
.
readLine
())
!=
null
)
{
json
.
append
(
str
);
}
in
.
close
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json
));
JSONObject
route
=
(
JSONObject
)
jsonObject
.
get
(
"route"
);
this
.
distance
=
route
.
get
(
"distance"
).
toString
();
this
.
taxi_cost
=
route
.
get
(
"taxi_cost"
).
toString
();
JSONArray
transits
=
route
.
getJSONArray
(
"transits"
);
JSONObject
temp0
=
transits
.
getJSONObject
(
Integer
.
parseInt
(
"0"
));
this
.
cost
=
temp0
.
get
(
"cost"
).
toString
();
this
.
duration
=
temp0
.
get
(
"duration"
).
toString
();
}
}
Java_2019-2020/期末大作业/src.com.company/ALiMap.java
0 → 100644
浏览文件 @
33720705
//高德地图
package
Map
;
import
java.io.IOException
;
import
java.util.Scanner
;
public
class
ALiMap
{
public
void
Geocode
()
throws
IOException
{
try
{
ALiGeocode
geocode0
=
new
ALiGeocode
();
System
.
out
.
println
(
"请输入地址(输入0可返回上一级菜单)"
);
geocode0
.
Do_geocode
();
if
(
geocode0
.
return0
==
1
){
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
System
.
out
.
println
(
"\n地址的结构化地址信息为:"
+
geocode0
.
formatted_address
);
System
.
out
.
println
(
"地址的区域编码为:"
+
geocode0
.
adcode
);
System
.
out
.
println
(
"地址的坐标点为:"
+
geocode0
.
location
+
"\n"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
public
void
Direction
()
throws
IOException
{
try
{
ALiGeocode
geocode1
=
new
ALiGeocode
();
ALiGeocode
geocode2
=
new
ALiGeocode
();
ALiIntegrated
integrated0
=
new
ALiIntegrated
();
ALiDriving
driving0
=
new
ALiDriving
();
ALiBicycling
bicycling0
=
new
ALiBicycling
();
System
.
out
.
println
(
"请输入出发点(输入0可返回上一级主菜单)"
);
geocode1
.
Do_geocode
();
if
(
geocode1
.
return0
==
1
){
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
integrated0
.
origin
=
geocode1
.
location
;
integrated0
.
city
=
geocode1
.
address
;
driving0
.
origin
=
geocode1
.
location
;
bicycling0
.
origin
=
geocode1
.
location
;
System
.
out
.
println
(
"请输入目的地(输入0可返回上一级菜单)"
);
geocode2
.
Do_geocode
();
if
(
geocode2
.
return0
==
1
){
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
integrated0
.
destination
=
geocode2
.
location
;
integrated0
.
cityd
=
geocode2
.
address
;
driving0
.
destination
=
geocode2
.
location
;
bicycling0
.
destination
=
geocode2
.
location
;
integrated0
.
Do_integrated
();
driving0
.
Do_driving
();
bicycling0
.
Do_bicycling
();
System
.
out
.
println
(
"\n起点和终点的步行距离:"
+
integrated0
.
distance
+
"米"
);
System
.
out
.
println
(
"出租车费用:"
+
integrated0
.
taxi_cost
+
"元"
);
System
.
out
.
println
(
"最快捷公交换乘方案价格:"
+
integrated0
.
cost
+
"元"
);
System
.
out
.
println
(
"最快捷公交换乘方案预计时间:"
+
integrated0
.
duration
+
"秒"
);
System
.
out
.
println
(
"行驶距离:"
+
driving0
.
distance
+
"米"
);
System
.
out
.
println
(
"预计行驶时间:"
+
driving0
.
duration
+
"秒"
);
System
.
out
.
println
(
"导航策略:"
+
driving0
.
strategy
);
System
.
out
.
println
(
"此导航方案道路收费:"
+
driving0
.
tolls
+
"元"
);
System
.
out
.
println
(
"此导航方案红绿灯个数:"
+
driving0
.
traffic_lights
+
"个"
);
System
.
out
.
println
(
"起终点的骑行距离:"
+
bicycling0
.
distance
+
"米"
);
System
.
out
.
println
(
"起终点的骑行时间:"
+
bicycling0
.
duration
+
"秒\n"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
public
void
Text
()
throws
IOException
{
try
{
ALiText
text0
=
new
ALiText
();
Scanner
scanner
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"请输入查询关键词(如:美食、学校)(输入0可返回上一级菜单)\n"
);
text0
.
keywords
=
scanner
.
nextLine
();
if
(
text0
.
keywords
.
equals
(
"0"
)){
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
System
.
out
.
print
(
"处理中"
);
// System.out.print("请输入查询类型");
// this.types=scanner.nextLine();
System
.
out
.
print
(
"请输入查询城市(仅限城市名,如:东莞、广州)(输入0可返回上一级菜单)\n"
);
text0
.
city
=
scanner
.
nextLine
();
if
(
text0
.
city
.
equals
(
"0"
)){
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
System
.
out
.
print
(
"处理中"
);
text0
.
Do_text
();
System
.
out
.
println
(
"\n\n名称:"
+
text0
.
name
);
System
.
out
.
println
(
"类型:"
+
text0
.
type
);
System
.
out
.
println
(
"地址:"
+
text0
.
pname
+
text0
.
cityname
+
text0
.
adname
+
text0
.
address
+
"\n"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
public
void
Around
()
throws
IOException
{
try
{
ALiAround
around0
=
new
ALiAround
();
ALiGeocode
geocode0
=
new
ALiGeocode
();
System
.
out
.
println
(
"请输入地点(输入0可返回上一级菜单)"
);
if
(
geocode0
.
return0
==
1
){
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
geocode0
.
Do_geocode
();
around0
.
location
=
geocode0
.
location
;
Scanner
scanner
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"请输入查询关键词(如:美食、学校)(输入0可返回上一级菜单)\n"
);
around0
.
keywords
=
scanner
.
nextLine
();
if
(
around0
.
keywords
.
equals
(
"0"
)){
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
System
.
out
.
print
(
"处理中"
);
around0
.
Do_around
();
System
.
out
.
println
(
"\n\n名称:"
+
around0
.
name
);
System
.
out
.
println
(
"类型:"
+
around0
.
type
);
System
.
out
.
println
(
"地址:"
+
around0
.
pname
+
around0
.
cityname
+
around0
.
adname
+
around0
.
address
+
"\n"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
public
void
Ip
()
throws
IOException
{
try
{
ALiIP
ip0
=
new
ALiIP
();
System
.
out
.
println
(
"请输入需要搜索的IP地址(仅支持国内)(输入0可返回上一级菜单)"
);
Scanner
scanner
=
new
Scanner
(
System
.
in
);
ip0
.
ip
=
scanner
.
nextLine
();
if
(
ip0
.
ip
.
equals
(
"0"
)){
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
System
.
out
.
print
(
"处理中"
);
ip0
.
Do_ip
();
System
.
out
.
println
(
"\n\nIP地址:"
+
ip0
.
province
+
ip0
.
city
+
"\n"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
public
void
WeatherInfo
()
throws
IOException
{
try
{
ALiGeocode
geocode0
=
new
ALiGeocode
();
ALiWeatherInfo
weatherInfo0
=
new
ALiWeatherInfo
();
System
.
out
.
println
(
"请输入地点(输入0可返回上一级菜单)"
);
geocode0
.
Do_geocode
();
if
(
geocode0
.
return0
==
1
){
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
weatherInfo0
.
city
=
geocode0
.
adcode
;
weatherInfo0
.
Do_weatherInfo
();
System
.
out
.
println
(
"\n"
+
geocode0
.
formatted_address
+
"今日的天气:"
);
System
.
out
.
println
(
"日期:\t\t\t\t\t"
+
weatherInfo0
.
date00
);
System
.
out
.
println
(
"星期:\t\t\t\t\t"
+
weatherInfo0
.
week00
);
System
.
out
.
println
(
"白天天气现象:\t\t\t"
+
weatherInfo0
.
dayweather00
);
System
.
out
.
println
(
"晚上天气现象:\t\t\t"
+
weatherInfo0
.
nightweather00
);
System
.
out
.
println
(
"白天温度(摄氏度):\t\t"
+
weatherInfo0
.
daytemp00
);
System
.
out
.
println
(
"晚上温度(摄氏度):\t\t"
+
weatherInfo0
.
nighttemp00
);
System
.
out
.
println
(
"白天风向:\t\t\t\t"
+
weatherInfo0
.
daywind00
);
System
.
out
.
println
(
"晚上风向:\t\t\t\t"
+
weatherInfo0
.
nightwind00
);
System
.
out
.
println
(
"白天风力(级):\t\t\t"
+
weatherInfo0
.
daypower00
);
System
.
out
.
println
(
"晚上风力(级):\t\t\t"
+
weatherInfo0
.
nightpower00
);
System
.
out
.
println
(
"\n"
+
geocode0
.
formatted_address
+
"未来三日的天气:"
);
System
.
out
.
println
(
"\n"
+
geocode0
.
formatted_address
+
"明日的天气:"
);
System
.
out
.
println
(
"日期:\t\t\t\t\t"
+
weatherInfo0
.
date01
);
System
.
out
.
println
(
"星期:\t\t\t\t\t"
+
weatherInfo0
.
week01
);
System
.
out
.
println
(
"白天天气现象:\t\t\t"
+
weatherInfo0
.
dayweather01
);
System
.
out
.
println
(
"晚上天气现象:\t\t\t"
+
weatherInfo0
.
nightweather01
);
System
.
out
.
println
(
"白天温度(摄氏度):\t\t"
+
weatherInfo0
.
daytemp01
);
System
.
out
.
println
(
"晚上温度(摄氏度):\t\t"
+
weatherInfo0
.
nighttemp01
);
System
.
out
.
println
(
"白天风向:\t\t\t\t"
+
weatherInfo0
.
daywind01
);
System
.
out
.
println
(
"晚上风向:\t\t\t\t"
+
weatherInfo0
.
nightwind01
);
System
.
out
.
println
(
"白天风力(级):\t\t\t"
+
weatherInfo0
.
daypower01
);
System
.
out
.
println
(
"晚上风力(级):\t\t\t"
+
weatherInfo0
.
nightpower01
);
System
.
out
.
println
(
"\n"
+
geocode0
.
formatted_address
+
"后天的天气:"
);
System
.
out
.
println
(
"日期:\t\t\t\t\t"
+
weatherInfo0
.
date02
);
System
.
out
.
println
(
"星期:\t\t\t\t\t"
+
weatherInfo0
.
week02
);
System
.
out
.
println
(
"白天天气现象:\t\t\t"
+
weatherInfo0
.
dayweather02
);
System
.
out
.
println
(
"晚上天气现象:\t\t\t"
+
weatherInfo0
.
nightweather02
);
System
.
out
.
println
(
"白天温度(摄氏度):\t\t"
+
weatherInfo0
.
daytemp02
);
System
.
out
.
println
(
"晚上温度(摄氏度):\t\t"
+
weatherInfo0
.
nighttemp02
);
System
.
out
.
println
(
"白天风向:\t\t\t\t"
+
weatherInfo0
.
daywind02
);
System
.
out
.
println
(
"晚上风向:\t\t\t\t"
+
weatherInfo0
.
nightwind02
);
System
.
out
.
println
(
"白天风力(级):\t\t\t"
+
weatherInfo0
.
daypower02
);
System
.
out
.
println
(
"晚上风力(级):\t\t\t"
+
weatherInfo0
.
nightpower02
);
System
.
out
.
println
(
"\n"
+
geocode0
.
formatted_address
+
"大后天的天气:"
);
System
.
out
.
println
(
"日期:\t\t\t\t\t"
+
weatherInfo0
.
date03
);
System
.
out
.
println
(
"星期:\t\t\t\t\t"
+
weatherInfo0
.
week03
);
System
.
out
.
println
(
"白天天气现象:\t\t\t"
+
weatherInfo0
.
dayweather03
);
System
.
out
.
println
(
"晚上天气现象:\t\t\t"
+
weatherInfo0
.
nightweather03
);
System
.
out
.
println
(
"白天温度(摄氏度):\t\t"
+
weatherInfo0
.
daytemp03
);
System
.
out
.
println
(
"晚上温度(摄氏度):\t\t"
+
weatherInfo0
.
nighttemp03
);
System
.
out
.
println
(
"白天风向:\t\t\t\t"
+
weatherInfo0
.
daywind03
);
System
.
out
.
println
(
"晚上风向:\t\t\t\t"
+
weatherInfo0
.
nightwind03
);
System
.
out
.
println
(
"白天风力(级):\t\t\t"
+
weatherInfo0
.
daypower03
);
System
.
out
.
println
(
"晚上风力(级):\t\t\t"
+
weatherInfo0
.
nightpower03
+
"\n"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
public
static
void
Alimap
()
throws
IOException
{
// write your code here
ALiMap
function
=
new
ALiMap
();
Scanner
scanner
=
new
Scanner
(
System
.
in
);
while
(
true
)
{
System
.
out
.
print
(
"选择功能\n"
);
System
.
out
.
print
(
"输入1——地理编码\n"
);
System
.
out
.
print
(
"输入2——路径规划\n"
);
System
.
out
.
print
(
"输入3——关键字搜索\n"
);
System
.
out
.
print
(
"输入4——周边搜索\n"
);
System
.
out
.
print
(
"输入5——IP定位\n"
);
System
.
out
.
print
(
"输入6——天气查询\n"
);
System
.
out
.
print
(
"输入0——返回主菜单\n"
);
String
Digit
=
scanner
.
nextLine
();
switch
(
Digit
)
{
case
"1"
:
function
.
Geocode
();
continue
;
case
"2"
:
function
.
Direction
();
continue
;
case
"3"
:
function
.
Text
();
continue
;
case
"4"
:
function
.
Around
();
continue
;
case
"5"
:
function
.
Ip
();
continue
;
case
"6"
:
function
.
WeatherInfo
();
continue
;
case
"0"
:
System
.
out
.
println
(
"\n返回主菜单\n"
);
return
;
default
:
System
.
out
.
println
(
"输入有误\n"
);
}
}
}
}
Java_2019-2020/期末大作业/src.com.company/ALiText.java
0 → 100644
浏览文件 @
33720705
package
Map
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
public
class
ALiText
{
public
String
keywords
;
public
String
types
;
public
String
city
;
public
String
name
;
public
String
type
;
public
String
address
;
public
String
pname
;
public
String
cityname
;
public
String
adname
;
public
void
Do_text
()
throws
IOException
{
StringBuilder
json
=
new
StringBuilder
();
URL
name
=
new
URL
(
"https://restapi.amap"
+
".com/v3/place/text?key=b3524cc502a4fc39c0d2a2e5cb97b516&keywords"
+
"="
+
this
.
keywords
+
"&types=&city="
+
this
.
city
+
"&children"
+
"=&offset=&page=&extensions=base"
);
// URL name = new URL("https://restapi.amap.com/v3/direction/transit/integrated" +
// "?key=b3524cc502a4fc39c0d2a2e5cb97b516&origin=116.481028,39" +
// ".989643&destination=116.434446,39" +
// ".90816&city=北京&cityd=北京&strategy=0&nightflag=0");
URLConnection
connection
=
name
.
openConnection
();
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
str
;
while
((
str
=
in
.
readLine
())
!=
null
)
{
json
.
append
(
str
);
}
in
.
close
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json
));
JSONArray
pois
=
jsonObject
.
getJSONArray
(
"pois"
);
JSONObject
temp0
=
pois
.
getJSONObject
(
Integer
.
parseInt
(
"0"
));
this
.
name
=
temp0
.
get
(
"name"
).
toString
();
this
.
type
=
temp0
.
get
(
"type"
).
toString
();
this
.
address
=
temp0
.
get
(
"address"
).
toString
();
this
.
pname
=
temp0
.
get
(
"pname"
).
toString
();
this
.
cityname
=
temp0
.
get
(
"cityname"
).
toString
();
this
.
adname
=
temp0
.
get
(
"adname"
).
toString
();
}
}
Java_2019-2020/期末大作业/src.com.company/ALiWeatherInfo.java
0 → 100644
浏览文件 @
33720705
package
Map
;
import
java.net.URL
;
import
java.io.*
;
import
java.net.URLConnection
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
public
class
ALiWeatherInfo
{
public
String
city
;
public
String
date00
;
public
String
dayweather00
;
public
String
daywind00
;
public
String
week00
;
public
String
daypower00
;
public
String
daytemp00
;
public
String
nightwind00
;
public
String
nighttemp00
;
public
String
nightweather00
;
public
String
nightpower00
;
public
String
date01
;
public
String
dayweather01
;
public
String
daywind01
;
public
String
week01
;
public
String
daypower01
;
public
String
daytemp01
;
public
String
nightwind01
;
public
String
nighttemp01
;
public
String
nightweather01
;
public
String
nightpower01
;
public
String
date02
;
public
String
dayweather02
;
public
String
daywind02
;
public
String
week02
;
public
String
daypower02
;
public
String
daytemp02
;
public
String
nightwind02
;
public
String
nighttemp02
;
public
String
nightweather02
;
public
String
nightpower02
;
public
String
date03
;
public
String
dayweather03
;
public
String
daywind03
;
public
String
week03
;
public
String
daypower03
;
public
String
daytemp03
;
public
String
nightwind03
;
public
String
nighttemp03
;
public
String
nightweather03
;
public
String
nightpower03
;
public
void
Do_weatherInfo
()
throws
IOException
{
StringBuilder
json
=
new
StringBuilder
();
URL
name
=
new
URL
(
"https://restapi.amap"
+
".com/v3/weather/weatherInfo?city="
+
this
.
city
+
"&extensions=all&key=b3524cc502a4fc39c0d2a2e5cb97b516"
);
// URL name = new URL("https://restapi.amap.com/v3/ip?ip=114.247.50" +
// ".2&output=json&key=b3524cc502a4fc39c0d2a2e5cb97b516");
URLConnection
connection
=
name
.
openConnection
();
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
str
;
while
((
str
=
in
.
readLine
())
!=
null
)
{
// System.out.print(str);
json
.
append
(
str
);
}
in
.
close
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json
));
JSONArray
forecasts
=
jsonObject
.
getJSONArray
(
"forecasts"
);
JSONObject
temp0
=
forecasts
.
getJSONObject
(
Integer
.
parseInt
(
"0"
));
JSONArray
casts
=
temp0
.
getJSONArray
(
"casts"
);
JSONObject
temp00
=
casts
.
getJSONObject
(
Integer
.
parseInt
(
"0"
));
JSONObject
temp01
=
casts
.
getJSONObject
(
Integer
.
parseInt
(
"1"
));
JSONObject
temp02
=
casts
.
getJSONObject
(
Integer
.
parseInt
(
"2"
));
JSONObject
temp03
=
casts
.
getJSONObject
(
Integer
.
parseInt
(
"3"
));
this
.
date00
=
temp00
.
get
(
"date"
).
toString
();
this
.
dayweather00
=
temp00
.
get
(
"dayweather"
).
toString
();
this
.
daywind00
=
temp00
.
get
(
"daywind"
).
toString
();
this
.
week00
=
temp00
.
get
(
"week"
).
toString
();
this
.
daypower00
=
temp00
.
get
(
"daypower"
).
toString
();
this
.
daytemp00
=
temp00
.
get
(
"daytemp"
).
toString
();
this
.
nightwind00
=
temp00
.
get
(
"nightwind"
).
toString
();
this
.
nighttemp00
=
temp00
.
get
(
"nighttemp"
).
toString
();
this
.
nightweather00
=
temp00
.
get
(
"nightweather"
).
toString
();
this
.
nightpower00
=
temp00
.
get
(
"nightpower"
).
toString
();
this
.
date01
=
temp01
.
get
(
"date"
).
toString
();
this
.
dayweather01
=
temp01
.
get
(
"dayweather"
).
toString
();
this
.
daywind01
=
temp01
.
get
(
"daywind"
).
toString
();
this
.
week01
=
temp01
.
get
(
"week"
).
toString
();
this
.
daypower01
=
temp01
.
get
(
"daypower"
).
toString
();
this
.
daytemp01
=
temp01
.
get
(
"daytemp"
).
toString
();
this
.
nightwind01
=
temp01
.
get
(
"nightwind"
).
toString
();
this
.
nighttemp01
=
temp01
.
get
(
"nighttemp"
).
toString
();
this
.
nightweather01
=
temp01
.
get
(
"nightweather"
).
toString
();
this
.
nightpower01
=
temp01
.
get
(
"nightpower"
).
toString
();
this
.
date02
=
temp02
.
get
(
"date"
).
toString
();
this
.
dayweather02
=
temp02
.
get
(
"dayweather"
).
toString
();
this
.
daywind02
=
temp02
.
get
(
"daywind"
).
toString
();
this
.
week02
=
temp02
.
get
(
"week"
).
toString
();
this
.
daypower02
=
temp02
.
get
(
"daypower"
).
toString
();
this
.
daytemp02
=
temp02
.
get
(
"daytemp"
).
toString
();
this
.
nightwind02
=
temp02
.
get
(
"nightwind"
).
toString
();
this
.
nighttemp02
=
temp02
.
get
(
"nighttemp"
).
toString
();
this
.
nightweather02
=
temp02
.
get
(
"nightweather"
).
toString
();
this
.
nightpower02
=
temp02
.
get
(
"nightpower"
).
toString
();
this
.
date03
=
temp03
.
get
(
"date"
).
toString
();
this
.
dayweather03
=
temp03
.
get
(
"dayweather"
).
toString
();
this
.
daywind03
=
temp03
.
get
(
"daywind"
).
toString
();
this
.
week03
=
temp03
.
get
(
"week"
).
toString
();
this
.
daypower03
=
temp03
.
get
(
"daypower"
).
toString
();
this
.
daytemp03
=
temp03
.
get
(
"daytemp"
).
toString
();
this
.
nightwind03
=
temp03
.
get
(
"nightwind"
).
toString
();
this
.
nighttemp03
=
temp03
.
get
(
"nighttemp"
).
toString
();
this
.
nightweather03
=
temp03
.
get
(
"nightweather"
).
toString
();
this
.
nightpower03
=
temp03
.
get
(
"nightpower"
).
toString
();
}
}
Java_2019-2020/期末大作业/src.com.company/BDIP.java
0 → 100644
浏览文件 @
33720705
//百度地图IP定位功能
package
Map
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
com.alibaba.fastjson.JSONObject
;
public
class
BDIP
{
public
String
ip
;
public
String
address
=
null
;
public
String
city_code
=
null
;
public
String
message
=
"0"
;
public
void
ip_location
()
throws
IOException
{
StringBuilder
json
=
new
StringBuilder
();
URL
URL
=
new
URL
(
"https://api.map.baidu.com/location/ip?ip="
+
ip
+
"&ak=75EYHRd9dg4ful7Qxwn1wWsMQjA3I0Ep&coor=bd09ll"
);
/*URL URL = new URL("https://api.map.baidu.com/location/ip?ip=183.63.102.207"
+ "&ak=75EYHRd9dg4ful7Qxwn1wWsMQjA3I0Ep&coor=bd09ll"); //测试URL*/
URLConnection
connection
=
URL
.
openConnection
();
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
URL
.
openStream
()));
String
inputLine
;
while
((
inputLine
=
in
.
readLine
())
!=
null
)
json
.
append
(
inputLine
);
in
.
close
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json
));
if
(
jsonObject
.
get
(
"status"
).
toString
().
equals
(
"0"
))
{
JSONObject
content
=
jsonObject
.
getJSONObject
(
"content"
);
JSONObject
address_detail
=
content
.
getJSONObject
(
"address_detail"
);
String
province
=
address_detail
.
get
(
"province"
).
toString
();
String
city
=
address_detail
.
get
(
"city"
).
toString
();
String
district
=
address_detail
.
get
(
"district"
).
toString
();
String
street
=
address_detail
.
get
(
"street"
).
toString
();
String
street_number
=
address_detail
.
get
(
"street_number"
).
toString
();
this
.
address
=
province
+
city
+
district
+
street
+
street_number
;
this
.
city_code
=
address_detail
.
get
(
"city_code"
).
toString
();
}
else
{
message
=
jsonObject
.
get
(
"message"
).
toString
();
System
.
out
.
println
(
"\n错误信息:"
+
message
+
"\n"
);
}
}
}
\ No newline at end of file
Java_2019-2020/期末大作业/src.com.company/BDMap.java
0 → 100644
浏览文件 @
33720705
//百度地图
package
Map
;
import
java.io.IOException
;
import
java.util.Scanner
;
public
class
BDMap
{
public
void
BDgeocode
()
throws
IOException
{
try
{
BDgeocode
geocode0
=
new
BDgeocode
();
System
.
out
.
print
(
"请输入需要查询的地点(输入 0 可返回上一级菜单):"
);
geocode0
.
geocode
();
if
(
geocode0
.
return0
==
1
)
{
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
System
.
out
.
println
(
"\n该地的坐标点为:"
+
geocode0
.
location
+
"\n"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
public
void
BDPathPlanning
()
throws
IOException
{
try
{
BDPathPlanning
pathplanning
=
new
BDPathPlanning
();
BDgeocode
geocode1
=
new
BDgeocode
();
BDgeocode
geocode2
=
new
BDgeocode
();
System
.
out
.
print
(
"请输入出发地(输入 0 可返回上一级菜单):"
);
geocode1
.
geocode
();
if
(
geocode1
.
return0
==
1
)
{
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
System
.
out
.
print
(
"请输入目的地:"
);
geocode2
.
geocode
();
System
.
out
.
println
(
"处理中..."
);
pathplanning
.
origin
=
geocode1
.
formatchange_location
;
pathplanning
.
destination
=
geocode2
.
formatchange_location
;
/*----------------------riding----------------------*/
pathplanning
.
riding
();
if
(
pathplanning
.
taxi_time_h
!=
0
)
{
System
.
out
.
println
(
"\n起点和终点的骑行距离为:"
+
pathplanning
.
riding_distance
+
"米,预计耗时"
+
pathplanning
.
riding_time_h
+
"小时"
+
pathplanning
.
riding_time_min
+
"分钟"
+
pathplanning
.
riding_time_s
+
"秒"
);
}
else
if
(
pathplanning
.
riding_time_min
!=
0
)
{
System
.
out
.
println
(
"\n起点和终点的骑行距离为:"
+
pathplanning
.
riding_distance
+
"米,预计耗时"
+
pathplanning
.
riding_time_min
+
"分钟"
+
pathplanning
.
riding_time_s
+
"秒"
);
}
else
System
.
out
.
println
(
"\n起点和终点的骑行距离为:"
+
pathplanning
.
riding_distance
+
"米,预计耗时"
+
pathplanning
.
riding_time_s
+
"秒"
);
/*-----------------------walk-----------------------*/
pathplanning
.
walking
();
if
(
pathplanning
.
walk_time_h
!=
0
)
{
System
.
out
.
println
(
"起点和终点的步行距离为:"
+
pathplanning
.
walk_distance
+
"米,预计耗时"
+
pathplanning
.
walk_time_h
+
"小时"
+
pathplanning
.
walk_time_min
+
"分钟"
+
pathplanning
.
walk_time_s
+
"秒"
);
}
else
if
(
pathplanning
.
walk_time_min
!=
0
)
{
System
.
out
.
println
(
"起点和终点的步行距离为:"
+
pathplanning
.
walk_distance
+
"米,预计耗时"
+
pathplanning
.
walk_time_min
+
"分钟"
+
pathplanning
.
walk_time_s
+
"秒"
);
}
else
System
.
out
.
println
(
"起点和终点的步行距离为:"
+
pathplanning
.
walk_distance
+
"米,预计耗时"
+
pathplanning
.
walk_time_s
+
"秒"
);
/*-----------------------taxi-----------------------*/
pathplanning
.
transit
();
if
(
pathplanning
.
taxi_time_h
!=
0
)
{
System
.
out
.
println
(
"出租车行驶距离为:"
+
pathplanning
.
taxi_distance
+
"米,预计耗时"
+
pathplanning
.
taxi_time_h
+
"小时"
+
pathplanning
.
taxi_time_min
+
"分钟"
+
pathplanning
.
taxi_time_s
+
"秒,预计费用为:"
+
pathplanning
.
taxi_cost
+
"元"
);
}
else
if
(
pathplanning
.
taxi_time_min
!=
0
)
{
System
.
out
.
println
(
"出租车行驶距离为:"
+
pathplanning
.
taxi_distance
+
"米,预计耗时"
+
pathplanning
.
taxi_time_min
+
"分钟"
+
pathplanning
.
taxi_time_s
+
"秒,预计费用为:"
+
pathplanning
.
taxi_cost
+
"元"
);
}
else
System
.
out
.
println
(
"出租车行驶距离为:"
+
pathplanning
.
taxi_distance
+
"米,预计耗时"
+
pathplanning
.
taxi_time_s
+
"秒,预计费用为:"
+
pathplanning
.
taxi_cost
+
"元"
);
/*-----------------------bus------------------------*/
if
(
pathplanning
.
bus_time_h
!=
0
)
{
System
.
out
.
println
(
"最快捷公交换乘方案价格为:"
+
pathplanning
.
bus_cost
+
"元,预计时间为"
+
pathplanning
.
bus_time_h
+
"小时"
+
pathplanning
.
bus_time_min
+
"分钟"
+
pathplanning
.
bus_time_s
+
"秒\n"
);
}
else
if
(
pathplanning
.
bus_time_min
!=
0
)
{
System
.
out
.
println
(
"最快捷公交换乘方案价格为:"
+
pathplanning
.
bus_cost
+
"元,预计时间为"
+
pathplanning
.
bus_time_min
+
"分钟"
+
pathplanning
.
bus_time_s
+
"秒\n"
);
}
else
System
.
out
.
println
(
"最快捷公交换乘方案价格为:"
+
pathplanning
.
bus_cost
+
"元,预计时间为"
+
pathplanning
.
bus_time_s
+
"秒\n"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
public
void
BDSearch
()
throws
IOException
{
try
{
BDSearch
search
=
new
BDSearch
();
Scanner
scanner
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"请输入需要检索的关键字(如:美食、银行、XX大厦等。输入 0 可返回上一级菜单):"
);
search
.
query
=
scanner
.
nextLine
();
if
(
search
.
query
.
equals
(
"0"
))
{
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
System
.
out
.
print
(
"请输入需要检索城市(仅限城市名,如:东莞、广州等):"
);
search
.
region
=
scanner
.
nextLine
();
System
.
out
.
println
(
"处理中..."
);
search
.
search
();
if
(
search
.
message
.
equals
(
"ok"
))
{
System
.
out
.
println
(
"\n检索结果 1 :"
);
System
.
out
.
println
(
"地点名:"
+
search
.
name0
);
System
.
out
.
println
(
"地址:"
+
search
.
address0
);
System
.
out
.
println
(
search
.
location0
+
"\n"
);
if
(
search
.
name1
.
equals
(
null
))
{
System
.
out
.
println
(
"检索结果 2 :"
);
System
.
out
.
println
(
"地点名:"
+
search
.
name1
);
System
.
out
.
println
(
"地址:"
+
search
.
address1
);
System
.
out
.
println
(
search
.
location1
+
"\n"
);
}
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
public
void
BDip
()
throws
IOException
{
BDIP
ip_location
=
new
BDIP
();
try
{
Scanner
scanner
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"请输入需要查询的IP地址(如果输入为空,默认查询本机;输入 0 可返回上一级菜单):"
);
ip_location
.
ip
=
scanner
.
nextLine
();
if
(
ip_location
.
ip
.
equals
(
"0"
))
{
System
.
out
.
println
(
"\n返回上一级菜单\n"
);
return
;
}
System
.
out
.
println
(
"处理中..."
);
ip_location
.
ip_location
();
if
(
ip_location
.
message
.
equals
(
"0"
))
{
System
.
out
.
println
(
"\n此IP地址的地址信息为:"
+
ip_location
.
address
);
System
.
out
.
println
(
"所在城市的百度城市代码为:"
+
ip_location
.
city_code
+
"\n"
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
public
static
void
BDmap
()
throws
IOException
{
BDMap
BDfunction
=
new
BDMap
();
Scanner
scanner
=
new
Scanner
(
System
.
in
);
while
(
true
)
{
System
.
out
.
println
(
"请输入对应数字选择功能:"
);
System
.
out
.
println
(
"1——地理编码"
);
System
.
out
.
println
(
"2——路径规划"
);
System
.
out
.
println
(
"3——地点检索"
);
System
.
out
.
println
(
"4——IP定位"
);
System
.
out
.
println
(
"0——返回主菜单"
);
int
Digit
=
scanner
.
nextInt
();
switch
(
Digit
)
{
case
1
:
BDfunction
.
BDgeocode
();
continue
;
case
2
:
BDfunction
.
BDPathPlanning
();
continue
;
case
3
:
BDfunction
.
BDSearch
();
continue
;
case
4
:
BDfunction
.
BDip
();
continue
;
case
0
:
System
.
out
.
println
(
"\n返回主菜单\n"
);
return
;
default
:
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
}
}
\ No newline at end of file
Java_2019-2020/期末大作业/src.com.company/BDPathPlanning.java
0 → 100644
浏览文件 @
33720705
//百度地图路径规划功能
package
Map
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONArray
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
public
class
BDPathPlanning
{
public
String
origin
;
public
String
destination
;
public
String
riding_distance
;
public
int
riding_time_h
;
public
int
riding_time_min
;
public
int
riding_time_s
;
public
String
walk_distance
;
public
int
walk_time_h
;
public
int
walk_time_min
;
public
int
walk_time_s
;
public
String
taxi_distance
;
public
int
taxi_time_h
;
public
int
taxi_time_min
;
public
int
taxi_time_s
;
public
String
taxi_cost
;
public
String
bus_cost
;
public
int
bus_time_h
;
public
int
bus_time_min
;
public
int
bus_time_s
;
public
void
riding
()
throws
IOException
{
StringBuilder
json1
=
new
StringBuilder
();
URL
URL1
=
new
URL
(
"http://api.map.baidu.com/directionlite/v1/riding?origin="
+
origin
+
"&destination="
+
destination
+
"&ak=75EYHRd9dg4ful7Qxwn1wWsMQjA3I0Ep"
);
/*URL URL1 = new URL("http://api.map.baidu.com/directionlite/v1/riding?" +
"origin=40.01116,116.339303&destination=39.936404,116.452562" +
"&ak=75EYHRd9dg4ful7Qxwn1wWsMQjA3I0Ep"); //测试URL */
//此处坐标格式为“纬度(double),经度(double)”,(小数点后不超过6位)
URLConnection
connection1
=
URL1
.
openConnection
();
connection1
.
setDoOutput
(
true
);
BufferedReader
in1
=
new
BufferedReader
(
new
InputStreamReader
(
URL1
.
openStream
()));
String
inputLine1
;
while
((
inputLine1
=
in1
.
readLine
())
!=
null
)
json1
.
append
(
inputLine1
);
in1
.
close
();
JSONObject
r_jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json1
));
JSONObject
result1
=
r_jsonObject
.
getJSONObject
(
"result"
);
JSONArray
Array_r_route
=
result1
.
getJSONArray
(
"routes"
);
//获取数组
JSONObject
r_route
=
Array_r_route
.
getJSONObject
(
0
);
riding_distance
=
r_route
.
get
(
"distance"
).
toString
();
String
riding_duration
=
r_route
.
get
(
"duration"
).
toString
();
//时间由“秒”换算为“时分秒”
int
riding_duration_h
=
0
;
int
riding_duration_min
=
0
;
int
riding_duration_s
=
0
;
if
(
Integer
.
parseInt
(
riding_duration
)
>
59
)
{
riding_duration_min
=
Integer
.
parseInt
(
riding_duration
)
/
60
;
riding_duration_s
=
Integer
.
parseInt
(
riding_duration
)
%
60
;
if
(
riding_duration_min
>
59
)
{
riding_duration_h
=
riding_duration_min
/
60
;
riding_duration_min
=
riding_duration_min
%
60
;
}
}
else
riding_time_s
=
Integer
.
parseInt
(
riding_duration
);
riding_time_h
=
riding_duration_h
;
riding_time_min
=
riding_duration_min
;
riding_time_s
=
riding_duration_s
;
}
public
void
walking
()
throws
IOException
{
StringBuilder
json2
=
new
StringBuilder
();
URL
URL2
=
new
URL
(
"http://api.map.baidu.com/directionlite/v1/walking?origin="
+
origin
+
"&destination="
+
destination
+
"&ak=75EYHRd9dg4ful7Qxwn1wWsMQjA3I0Ep"
);
/*URL URL2 = new URL("http://api.map.baidu.com/directionlite/v1/walking?" +
"origin=40.01116,116.339303&destination=39.936404,116.452562" +
"&ak=75EYHRd9dg4ful7Qxwn1wWsMQjA3I0Ep"); //测试URL */
//此处坐标格式为“纬度(double),经度(double)”,(小数点后不超过6位)
URLConnection
connection2
=
URL2
.
openConnection
();
connection2
.
setDoOutput
(
true
);
BufferedReader
in2
=
new
BufferedReader
(
new
InputStreamReader
(
URL2
.
openStream
()));
String
inputLine2
;
while
((
inputLine2
=
in2
.
readLine
())
!=
null
)
json2
.
append
(
inputLine2
);
in2
.
close
();
JSONObject
w_jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json2
));
JSONObject
result2
=
w_jsonObject
.
getJSONObject
(
"result"
);
JSONArray
Array_w_route
=
result2
.
getJSONArray
(
"routes"
);
//获取数组
JSONObject
w_route
=
Array_w_route
.
getJSONObject
(
0
);
walk_distance
=
w_route
.
get
(
"distance"
).
toString
();
String
walk_duration
=
w_route
.
get
(
"duration"
).
toString
();
//时间由“秒”换算为“时分秒”
int
walk_duration_h
=
0
;
int
walk_duration_min
=
0
;
int
walk_duration_s
=
0
;
if
(
Integer
.
parseInt
(
walk_duration
)
>
59
)
{
walk_duration_min
=
Integer
.
parseInt
(
walk_duration
)
/
60
;
walk_duration_s
=
Integer
.
parseInt
(
walk_duration
)
%
60
;
if
(
walk_duration_min
>
59
)
{
walk_duration_h
=
walk_duration_min
/
60
;
walk_duration_min
=
walk_duration_min
%
60
;
}
}
else
walk_time_s
=
Integer
.
parseInt
(
walk_duration
);
walk_time_h
=
walk_duration_h
;
walk_time_min
=
walk_duration_min
;
walk_time_s
=
walk_duration_s
;
}
public
void
transit
()
throws
IOException
{
StringBuilder
json3
=
new
StringBuilder
();
URL
URL3
=
new
URL
(
"http://api.map.baidu.com/directionlite/v1/transit?origin="
+
origin
+
"&destination="
+
destination
+
"&ak=75EYHRd9dg4ful7Qxwn1wWsMQjA3I0Ep"
);
//URL URL3 = new URL("http://api.map.baidu.com/directionlite/v1/transit?origin=40.01116,116.339303&destination=39.936404,116.452562&ak=75EYHRd9dg4ful7Qxwn1wWsMQjA3I0Ep");//����URL
//此处坐标格式为“纬度(double),经度(double)”,(小数点后不超过6位)
URLConnection
connection1
=
URL3
.
openConnection
();
connection1
.
setDoOutput
(
true
);
BufferedReader
in3
=
new
BufferedReader
(
new
InputStreamReader
(
URL3
.
openStream
()));
String
inputLine3
;
while
((
inputLine3
=
in3
.
readLine
())
!=
null
)
json3
.
append
(
inputLine3
);
in3
.
close
();
JSONObject
t_jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json3
));
JSONObject
result3
=
t_jsonObject
.
getJSONObject
(
"result"
);
/*----------------taxi----------------*/
JSONObject
taxi
=
result3
.
getJSONObject
(
"taxi"
);
taxi_distance
=
taxi
.
getString
(
"distance"
).
toString
();
String
taxi_duration
=
taxi
.
getString
(
"duration"
).
toString
();
int
taxi_duration_h
=
0
;
int
taxi_duration_min
=
0
;
int
taxi_duration_s
=
0
;
if
(
Integer
.
parseInt
(
taxi_duration
)
>
59
)
{
taxi_duration_min
=
Integer
.
parseInt
(
taxi_duration
)
/
60
;
taxi_duration_s
=
Integer
.
parseInt
(
taxi_duration
)
%
60
;
if
(
taxi_duration_min
>
59
)
{
taxi_duration_h
=
taxi_duration_min
/
60
;
taxi_duration_min
=
taxi_duration_min
%
60
;
}
}
else
taxi_duration_s
=
Integer
.
parseInt
(
taxi_duration
);
taxi_time_h
=
taxi_duration_h
;
taxi_time_min
=
taxi_duration_min
;
taxi_time_s
=
taxi_duration_s
;
JSONArray
taxi_detail
=
taxi
.
getJSONArray
(
"detail"
);
//获取数组
JSONObject
t_cost
=
taxi_detail
.
getJSONObject
(
0
);
taxi_cost
=
t_cost
.
get
(
"total_price"
).
toString
();
/*----------------bus----------------*/
JSONArray
b_route
=
result3
.
getJSONArray
(
"routes"
);
//获取数组
JSONObject
best_bus_route
=
b_route
.
getJSONObject
(
0
);
bus_cost
=
best_bus_route
.
getJSONArray
(
"line_price"
).
getJSONObject
(
0
).
get
(
"line_price"
).
toString
();
String
bus_duration
=
best_bus_route
.
get
(
"duration"
).
toString
();
//时间由“秒”换算为“时分秒”
int
bus_duration_h
=
0
;
int
bus_duration_min
=
0
;
int
bus_duration_s
=
0
;
if
(
Integer
.
parseInt
(
bus_duration
)
>
59
)
{
bus_duration_min
=
Integer
.
parseInt
(
bus_duration
)
/
60
;
bus_duration_s
=
Integer
.
parseInt
(
bus_duration
)
%
60
;
if
(
bus_duration_min
>
59
)
{
bus_duration_h
=
bus_duration_min
/
60
;
bus_duration_min
=
bus_duration_min
%
60
;
}
}
else
bus_duration_s
=
Integer
.
parseInt
(
bus_duration
);
bus_time_h
=
bus_duration_h
;
bus_time_min
=
bus_duration_min
;
bus_time_s
=
bus_duration_s
;
}
}
\ No newline at end of file
Java_2019-2020/期末大作业/src.com.company/BDSearch.java
0 → 100644
浏览文件 @
33720705
//百度地图地点检索功能
package
Map
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
public
class
BDSearch
{
public
String
query
;
public
String
region
;
public
String
name0
=
null
;
public
String
address0
=
null
;
public
String
location0
=
null
;
public
String
name1
=
"0"
;
public
String
address1
=
null
;
public
String
location1
=
null
;
public
String
message
=
null
;
public
void
search
()
throws
IOException
{
StringBuilder
json
=
new
StringBuilder
();
URL
URL
=
new
URL
(
"http://api.map.baidu.com/place/v2/search?query="
+
query
+
"®ion="
+
region
+
"&page_size=2&output=json&ak=75EYHRd9dg4ful7Qxwn1wWsMQjA3I0Ep"
);
/*URL URL = new URL("http://api.map.baidu.com/place/v2/search?query=ATM机&tag=银行®ion=广州"
+ "&output=json&ak=75EYHRd9dg4ful7Qxwn1wWsMQjA3I0Ep"); //测试URL*/
URLConnection
connection
=
URL
.
openConnection
();
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
URL
.
openStream
()));
String
inputLine
;
while
((
inputLine
=
in
.
readLine
())
!=
null
)
json
.
append
(
inputLine
);
in
.
close
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json
));
if
(
jsonObject
.
get
(
"status"
).
toString
().
equals
(
"0"
))
{
message
=
jsonObject
.
get
(
"message"
).
toString
();
JSONArray
result
=
jsonObject
.
getJSONArray
(
"results"
);
JSONObject
info0
=
result
.
getJSONObject
(
0
);
name0
=
info0
.
get
(
"name"
).
toString
();
address0
=
info0
.
get
(
"address"
).
toString
();
JSONObject
locat0
=
info0
.
getJSONObject
(
"location"
);
location0
=
"经度:"
+
locat0
.
get
(
"lng"
).
toString
()
+
",纬度:"
+
locat0
.
get
(
"lat"
).
toString
();
JSONObject
info1
=
result
.
getJSONObject
(
1
);
name1
=
info1
.
get
(
"name"
).
toString
();
address1
=
info1
.
get
(
"address"
).
toString
();
JSONObject
locat1
=
info1
.
getJSONObject
(
"location"
);
location1
=
"经度:"
+
locat1
.
get
(
"lng"
).
toString
()
+
",纬度:"
+
locat1
.
get
(
"lat"
).
toString
();
}
else
{
message
=
jsonObject
.
get
(
"message"
).
toString
();
System
.
out
.
println
(
"\n错误信息:"
+
message
+
"\n"
);
}
}
}
\ No newline at end of file
Java_2019-2020/期末大作业/src.com.company/BDgeocode.java
0 → 100644
浏览文件 @
33720705
//百度地图地理编码功能
package
Map
;
import
com.alibaba.fastjson.JSONObject
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.text.DecimalFormat
;
import
java.util.Scanner
;
public
class
BDgeocode
{
public
int
return0
;
public
String
address
;
public
String
location
;
public
String
formatchange_location
;
public
void
geocode
()
throws
IOException
{
StringBuilder
json
=
new
StringBuilder
();
Scanner
scanner
=
new
Scanner
(
System
.
in
);
address
=
scanner
.
nextLine
();
if
(
address
.
equals
(
"0"
))
{
return0
=
1
;
return
;
}
URL
URL
=
new
URL
(
"http://api.map.baidu.com/geocoding/v3/?address="
+
address
+
"&output=json&ak=75EYHRd9dg4ful7Qxwn1wWsMQjA3I0Ep"
);
URLConnection
connection
=
URL
.
openConnection
();
connection
.
setDoOutput
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
URL
.
openStream
()));
String
inputLine
;
while
((
inputLine
=
in
.
readLine
())
!=
null
)
json
.
append
(
inputLine
);
in
.
close
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
String
.
valueOf
(
json
));
JSONObject
result
=
jsonObject
.
getJSONObject
(
"result"
);
JSONObject
location
=
result
.
getJSONObject
(
"location"
);
this
.
location
=
"经度:"
+
location
.
get
(
"lng"
).
toString
()
+
",纬度:"
+
location
.
get
(
"lat"
).
toString
();
String
lng
=
location
.
get
(
"lng"
).
toString
();
String
lat
=
location
.
get
(
"lat"
).
toString
();
this
.
formatchange_location
=
FormatChange
(
lng
,
lat
);
}
public
String
FormatChange
(
String
a
,
String
b
)
throws
IOException
{
//接收坐标为:“经度,纬度”
DecimalFormat
df
=
new
DecimalFormat
(
"0.000000"
);
float
f1
=
Float
.
parseFloat
(
a
);
float
f2
=
Float
.
parseFloat
(
b
);
String
s1
=
df
.
format
(
f1
);
String
s2
=
df
.
format
(
f2
);
String
s
=
s2
+
","
+
s1
;
//此时转换后坐标为:“纬度,经度”
return
s
;
}
}
\ No newline at end of file
Java_2019-2020/期末大作业/src.com.company/MapMain.java
0 → 100644
浏览文件 @
33720705
/************************************************************
*JAVA程序设计-大作业 *
*作品名称:地图系统 *
*作者:梁志浩(20172333075)、何尔恒(2017233****) *
*该地图系统可选择使用高德地图或百度地图 *
*为确保程序正常使用,请添加 lib 目录下 fastjson-1.2.62.jar *
************************************************************/
package
Map
;
import
java.io.IOException
;
import
java.util.Scanner
;
public
class
MapMain
{
public
static
void
welcome
()
{
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
Scanner
scanner
=
new
Scanner
(
System
.
in
);
while
(
true
)
{
System
.
out
.
println
(
"****欢迎使用地图程序,请输入对应数字选择地图****"
);
System
.
out
.
println
(
"1——高德地图"
);
System
.
out
.
println
(
"2——百度地图"
);
System
.
out
.
println
(
"0——退出程序"
);
int
Digit
=
scanner
.
nextInt
();
switch
(
Digit
)
{
case
1
:
System
.
out
.
println
(
"欢迎使用高德地图!"
);
ALiMap
.
Alimap
();
continue
;
case
2
:
System
.
out
.
println
(
"欢迎使用百度地图!"
);
BDMap
.
BDmap
();
continue
;
case
0
:
System
.
out
.
println
(
"程序结束"
);
System
.
exit
(
0
);
scanner
.
close
();
//当此后非程序结束,须删除此行
continue
;
default
:
System
.
out
.
println
(
"\n输入有误\n"
);
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录