Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/main/java/tech/spiro/addrparser/common/RegionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class RegionInfo {
private final String name;
private final RegionLevel level;
private final Point center;
private final List<List<Point>> polyline;

private final ContainPointJudge containPointJudge = ContainPointJudgeFactory.create();

Expand All @@ -26,8 +25,7 @@ private RegionInfo(Builder builder) {
this.name = builder.name;
this.level = builder.level;
this.center = builder.center;
this.polyline = Collections.unmodifiableList(builder.polyline);
containPointJudge.initPolygons(this.polyline);
containPointJudge.initPolygons(Collections.unmodifiableList(builder.polyline));
}

public int getParentCode() {
Expand All @@ -50,9 +48,6 @@ public Point getCenter() {
return center;
}

public List<List<Point>> getPolyline() {
return polyline;
}

public boolean contain(Point point) {
return this.containPointJudge.contain(point);
Expand Down
36 changes: 36 additions & 0 deletions src/test/java/tech/spiro/addrparser/demo/RunDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package tech.spiro.addrparser.demo;

import com.mysql.cj.jdbc.MysqlDataSource;
import tech.spiro.addrparser.common.Point;
import tech.spiro.addrparser.io.RegionDataInput;
import tech.spiro.addrparser.io.rdbms.RdbmsRegionDataInput;
import tech.spiro.addrparser.parser.Location;
import tech.spiro.addrparser.parser.LocationParserEngine;
import tech.spiro.addrparser.parser.ParserEngineException;

import java.io.IOException;

/**
* @description:
* @author: xiaochangbai
* @date: 2022/12/14 9:51
*/
public class RunDemo {

public static void main(String[] args) throws ParserEngineException, IOException {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setServerName("fat-mysql.i");
dataSource.setPort(3306);
dataSource.setDatabaseName("express_i");
dataSource.setUser("express");
dataSource.setPassword("2c7d7847f82071");
RegionDataInput regionDataInput = new RdbmsRegionDataInput(dataSource);
LocationParserEngine engine = new LocationParserEngine(regionDataInput);
engine.init();
System.out.println("初始化完成");
Location location = engine.parse(new Point(116.708463,23.37102));
System.out.println(location);

}

}