New file |
| | |
| | | package safeluck.drive.evaluation.bean; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * DriveJudge |
| | | * Created by lzw on 2020/12/1. 16:40:59 |
| | | * 邮箱:632393724@qq.com |
| | | * All Rights Saved! Chongqing AnYun Tech co. LTD |
| | | */ |
| | | public class RoadExamMap3 { |
| | | |
| | | /** |
| | | * name : 涪陵交通驾校road新增 |
| | | * points : [428097.3494,3292398.695,428839.3222,3292353.4694,428904.1984,3292342.3202,428909.2188,3292339.5687,428912.7048,3292335.2346,428914.3318,3292329.5423,428914.6448,3292229.2849,428914.3495,3292199.2617,427794.2684,3291847.891,427843.6031,3291848.2677,427794.2538,3291837.5986,427843.6031,3291837.5968,427794.2634,3291844.3909,427813.6031,3291844.3819,427843.6032,3291844.3677,427794.2585,3291840.8909,427813.6032,3291840.8819,427843.6031,3291840.8677,427889.6681,3291847.846,428859.3318,3291847.3888,428867.0733,3291849.9062,428872.3885,3291854.6058,427889.5344,3291837.553,428859.2109,3291837.0889,428867.8127,3291838.5584,428874.5509,3291842.4758,428879.5036,3291848.2172,428882.2786,3291854.9625,427889.5864,3291844.346,428859.3301,3291843.8888,427889.6754,3291840.846,428859.3284,3291840.3888,428871.961,3291854.9222,428866.767,3291850.2715,428859.332,3291847.7888,427889.6054,3291848.246,428868.1235,3291860.6933,428866.8461,3291859.1589,428864.0891,3291858.1862,428859.5321,3291858.1876,427889.6569,3291858.4876,428859.3337,3291851.2888,427920.2527,3291851.7316,427890.1442,3291851.7458,428859.3354,3291854.7888,427919.9881,3291855.2317,427889.6601,3291855.246,427843.6083,3291847.8677,427794.269,3291848.291,427843.6031,3291858.6714,427794.2836,3291858.6265,427843.6031,3291851.7677,427794.2739,3291851.791,427843.7076,3291855.2677,427794.2789,3291855.291] |
| | | * red_line : [{"id":0,"points":[291,292],"type":4},{"id":1,"points":[292,294],"type":4},{"id":2,"points":[295,296,297,298,299,300,301,302,303,304,305,306,307,308,309],"type":1},{"id":3,"points":[310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326],"type":1},{"id":4,"points":[327,328],"type":4},{"id":5,"points":[329,330],"type":4},{"id":6,"points":[331,332],"type":4}] |
| | | * road : [{"active":0,"crossing":[{"active":2,"center_point":55,"line":[26,140],"stop_flag":0,"tts":"路口左转弯"}],"id":10,"left_edge":[{"line":[352,353,354,355,356,357,358,359,360,361,362,363,364],"type":1}],"next_road":11,"right_edge":[{"line":[333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351],"type":1}],"separate":[{"lane_guide":[{"guide":[2,1,1],"head_tail":[379,380]}],"lane_line":[[{"line":[365,366,367,368,369,370,371,372,373,374,375,376,377,378,379],"type":0},{"line":[379,380],"type":1}],[{"line":[381,382,383,384,385,386,387,388,389,390,391,392,393,394],"type":0},{"line":[394,395],"type":1}]]}],"start_line":[352,333]},{"active":0,"crossing":[{"active":2,"center_point":55,"line":[26,140],"stop_flag":0,"tts":"路口左转弯"}],"id":11,"left_edge":[{"line":[396,397],"type":1}],"next_road":12,"right_edge":[{"line":[398,399,400,401,402],"type":1}],"separate":[{"lane_guide":[{"guide":[4,2,2],"head_tail":[404,405]}],"lane_line":[[{"line":[403,404],"type":0},{"line":[404,405],"type":1}],[{"line":[406,407],"type":0},{"line":[407,408],"type":1}]]}],"start_line":[396,398]},{"active":0,"crossing":[{"active":2,"center_point":55,"line":[26,140],"stop_flag":0,"tts":"路口左转弯"}],"id":13,"left_edge":[{"line":[409,410],"type":1}],"next_road":14,"right_edge":[{"line":[425,426],"type":1}],"separate":[{"lane_guide":[{"guide":[8,1,4],"head_tail":[444,445]}],"lane_line":[[{"line":[443,444],"type":0},{"line":[444,445],"type":1}],[{"line":[446,447],"type":0},{"line":[447,448],"type":1}]]}],"start_line":[409,425]},{"active":0,"crossing":[{"active":2,"center_point":55,"line":[26,140],"stop_flag":0,"tts":"路口左转弯"}],"id":14,"left_edge":[{"line":[411,412,413,414,415,416,417,418,419,420,421,422,423,424],"type":1}],"next_road":1,"right_edge":[{"line":[427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442],"type":1}],"separate":[{"lane_guide":[{"guide":[4,1,1],"head_tail":[461,462]}],"lane_line":[[{"line":[449,450,451,452,453,454,455,456,457,458,459,460,461],"type":0},{"line":[461,462],"type":1}],[{"line":[463,464,465,466,467,468,469,470,471,472,473,474,475],"type":0},{"line":[475,476],"type":1}]]}],"start_line":[411,427]},{"active":0,"crossing":[{"active":2,"center_point":55,"line":[26,140],"stop_flag":0,"tts":"路口左转弯"}],"id":15,"left_edge":[{"line":[477,478],"type":1}],"next_road":16,"right_edge":[{"line":[479,480],"type":1}],"separate":[{"lane_guide":[{"guide":[2,1,1],"head_tail":[482,483]}],"lane_line":[[{"line":[481,482],"type":0},{"line":[482,483],"type":1}],[{"line":[484,485],"type":0},{"line":[485,486],"type":1}]]}],"start_line":[477,479]},{"active":0,"crossing":[{"active":2,"center_point":55,"line":[26,140],"stop_flag":0,"tts":"路口左转弯"}],"id":16,"left_edge":[{"line":[487,488,489,490],"type":1}],"next_road":1,"right_edge":[{"line":[491,492,493,494,495,496],"type":1}],"separate":[{"lane_line":[[{"line":[497,498],"type":0}],[{"line":[499,500],"type":0}]]}],"start_line":[487,491]},{"active":0,"crossing":[{"active":2,"center_point":55,"line":[26,140],"stop_flag":0,"tts":"路口左转弯"}],"id":17,"left_edge":[{"line":[501,502,503,504],"type":1}],"next_road":1,"right_edge":[{"line":[505,506,507,508,509],"type":1}],"separate":[{"lane_guide":[{"guide":[8,1,4],"head_tail":[511,512]}],"lane_line":[[{"line":[510,511],"type":0},{"line":[511,512],"type":1}],[{"line":[513,514],"type":0},{"line":[514,515],"type":1}]]}],"start_line":[501,505]},{"active":0,"crossing":[{"active":2,"center_point":55,"line":[26,140],"stop_flag":0,"tts":"路口左转弯"}],"id":18,"left_edge":[{"line":[516,517],"type":1}],"next_road":16,"right_edge":[{"line":[518,519],"type":1}],"separate":[{"lane_line":[[{"line":[520,521],"type":0}],[{"line":[522,523],"type":0}]]}],"start_line":[516,518]},{"active":0,"crossing":[{"active":2,"center_point":55,"line":[26,140],"stop_flag":0,"tts":"路口左转弯"}],"id":1,"left_edge":[{"line":[118,121,123,125,127,129,132,137,140],"type":1}],"next_road":2,"right_edge":[{"line":[0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26],"type":1}],"separate":[{"lane_line":[[{"line":[117,120,122,124,126,128,131],"type":0}]]},{"lane_guide":[{"guide":[2,1,4],"head_tail":[135,139]}],"lane_line":[[{"line":[131,135],"type":0},{"line":[135,139],"type":1}],[{"line":[130,133],"type":0},{"line":[133,138],"type":1}]]}],"start_line":[0,118]},{"active":0,"crossing":[{"active":1,"center_point":0,"line":[37,178],"stop_flag":0,"tts":"通过路口"}],"id":2,"left_edge":[{"line":[155,157,162,165,168,171,178],"type":1}],"next_road":5,"right_edge":[{"line":[28,29,30,31,32,33,34,35,36,37],"type":1}],"separate":[{"lane_guide":[{"guide":[1,1,4],"head_tail":[174,177]}],"lane_line":[[{"line":[159,161,164,167,170,174],"type":0},{"line":[174,177],"type":1}],[{"line":[158,160,163,166,169,172],"type":0},{"line":[172,176],"type":1}]]}],"start_line":[28,155]},{"active":0,"crossing":[{"active":1,"center_point":0,"line":[81,245],"stop_flag":0,"tts":"通过路口"}],"id":3,"left_edge":[{"line":[217,223,226,229,232,235,238,245],"type":1}],"next_road":6,"right_edge":[{"line":[64,66,67,68,69,70,71,72,73,76,78,80,85],"type":1}],"separate":[{"lane_guide":[{"guide":[2,1,1],"head_tail":[239,243]}],"lane_line":[[{"line":[220,222,225,228,231,234,237,241],"type":0},{"line":[241,244],"type":1}],[{"line":[219,221,224,227,230,233,236,239],"type":0},{"line":[239,243],"type":1}]]}],"start_line":[64,217]},{"active":0,"crossing":[{"active":8,"center_point":0,"line":[115,153],"stop_flag":0,"tts":"调头"}],"id":4,"left_edge":[{"line":[141,145,147,149,153],"type":1}],"next_road":0,"right_edge":[{"line":[104,106,107,108,109,110,111,112,113,114,115],"type":1}],"separate":[{"lane_guide":[{"guide":[3,1],"head_tail":[150,152]}],"lane_line":[[{"line":[143,144,146,148,150],"type":0},{"line":[150,152],"type":1}]]}],"start_line":[101,141]},{"active":8,"crossing":[{"active":8,"center_point":0,"line":[62,215],"stop_flag":0,"tts":"掉头"}],"id":5,"left_edge":[{"line":[184,188,191,194,197,200,203,206,209,212,215],"type":1}],"next_road":3,"right_edge":[{"line":[40,42,43,44,45,48,51,54,55,56,57,58,59,60,61,62],"type":1}],"separate":[{"lane_line":[[{"line":[183,187,190,193,196,199,202,205,208,211,214],"type":0}],[{"line":[182,186,189,192,195,198,201,204,207,210,213],"type":0}]]}],"start_line":[180,184]},{"active":0,"crossing":[{"active":4,"center_point":0,"line":[98,285],"stop_flag":0,"tts":"路口右转弯"}],"id":6,"left_edge":[{"line":[249,253,256,259,262,263,268,271,274,279,282,285],"type":1}],"next_road":4,"right_edge":[{"line":[85,86,87,89,92,93,94,95,96,97,98],"type":1}],"separate":[{"lane_guide":[{"guide":[2,1,5],"head_tail":[275,283]}],"lane_line":[[{"line":[248,252,255,258,261,264,267,270,273,277],"type":0},{"line":[277,281,284],"type":1}],[{"line":[247,251,254,257,260,265,266,269,272,275],"type":0},{"line":[275,280,283],"type":1}]]}],"start_line":[85,249]}] |
| | | * special_area : [{"area":[39,40],"id":0,"road":2,"type":0},{"area":[45,47],"id":1,"road":5,"type":0},{"area":[48,50],"id":2,"road":5,"type":2},{"area":[51,53],"id":3,"road":5,"type":0},{"area":[73,75],"id":4,"road":3,"type":0},{"area":[76,78],"id":5,"road":3,"type":2},{"area":[82,83],"id":6,"road":3,"type":0},{"area":[83,87],"id":7,"road":6,"type":1},{"area":[89,91],"id":8,"road":6,"type":0},{"area":[100,101],"id":9,"road":6,"type":0},{"area":[102,104],"id":10,"road":4,"type":0},{"area":[180,43],"id":11,"road":5,"type":1}] |
| | | * trigger_line : [{"id":0,"line":[287],"road":5,"tts":"变更车道","type":1},{"id":1,"line":[288],"road":5,"tts":"加减档","type":4},{"id":2,"line":[289],"road":3,"tts":"直线行驶","type":3},{"id":3,"line":[290],"road":3,"tts":"超车","type":2}] |
| | | * type : road |
| | | */ |
| | | |
| | | private String name; |
| | | private String type; |
| | | private List<Double> points; |
| | | private List<RedLineBean> red_line; |
| | | private List<RoadBean> road; |
| | | private List<SpecialAreaBean> special_area; |
| | | private List<TriggerLineBean> trigger_line; |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(String type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public List<Double> getPoints() { |
| | | return points; |
| | | } |
| | | |
| | | public void setPoints(List<Double> points) { |
| | | this.points = points; |
| | | } |
| | | |
| | | public List<RedLineBean> getRed_line() { |
| | | return red_line; |
| | | } |
| | | |
| | | public void setRed_line(List<RedLineBean> red_line) { |
| | | this.red_line = red_line; |
| | | } |
| | | |
| | | public List<RoadBean> getRoad() { |
| | | return road; |
| | | } |
| | | |
| | | public void setRoad(List<RoadBean> road) { |
| | | this.road = road; |
| | | } |
| | | |
| | | public List<SpecialAreaBean> getSpecial_area() { |
| | | return special_area; |
| | | } |
| | | |
| | | public void setSpecial_area(List<SpecialAreaBean> special_area) { |
| | | this.special_area = special_area; |
| | | } |
| | | |
| | | public List<TriggerLineBean> getTrigger_line() { |
| | | return trigger_line; |
| | | } |
| | | |
| | | public void setTrigger_line(List<TriggerLineBean> trigger_line) { |
| | | this.trigger_line = trigger_line; |
| | | } |
| | | |
| | | public static class RedLineBean { |
| | | /** |
| | | * id : 0 |
| | | * points : [291,292] |
| | | * type : 4 |
| | | */ |
| | | |
| | | private int id; |
| | | private int type; |
| | | private List<Integer> points; |
| | | |
| | | public int getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(int id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public List<Integer> getPoints() { |
| | | return points; |
| | | } |
| | | |
| | | public void setPoints(List<Integer> points) { |
| | | this.points = points; |
| | | } |
| | | } |
| | | |
| | | public static class RoadBean { |
| | | /** |
| | | * active : 0 |
| | | * crossing : [{"active":2,"center_point":55,"line":[26,140],"stop_flag":0,"tts":"路口左转弯"}] |
| | | * id : 10 |
| | | * left_edge : [{"line":[352,353,354,355,356,357,358,359,360,361,362,363,364],"type":1}] |
| | | * next_road : 11 |
| | | * right_edge : [{"line":[333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351],"type":1}] |
| | | * separate : [{"lane_guide":[{"guide":[2,1,1],"head_tail":[379,380]}],"lane_line":[[{"line":[365,366,367,368,369,370,371,372,373,374,375,376,377,378,379],"type":0},{"line":[379,380],"type":1}],[{"line":[381,382,383,384,385,386,387,388,389,390,391,392,393,394],"type":0},{"line":[394,395],"type":1}]]}] |
| | | * start_line : [352,333] |
| | | */ |
| | | |
| | | private int active; |
| | | private int id; |
| | | private int next_road; |
| | | private List<CrossingBean> crossing; |
| | | private List<LeftEdgeBean> left_edge; |
| | | private List<RightEdgeBean> right_edge; |
| | | private List<SeparateBean> separate; |
| | | private List<Integer> start_line; |
| | | |
| | | public int getActive() { |
| | | return active; |
| | | } |
| | | |
| | | public void setActive(int active) { |
| | | this.active = active; |
| | | } |
| | | |
| | | public int getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(int id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public int getNext_road() { |
| | | return next_road; |
| | | } |
| | | |
| | | public void setNext_road(int next_road) { |
| | | this.next_road = next_road; |
| | | } |
| | | |
| | | public List<CrossingBean> getCrossing() { |
| | | return crossing; |
| | | } |
| | | |
| | | public void setCrossing(List<CrossingBean> crossing) { |
| | | this.crossing = crossing; |
| | | } |
| | | |
| | | public List<LeftEdgeBean> getLeft_edge() { |
| | | return left_edge; |
| | | } |
| | | |
| | | public void setLeft_edge(List<LeftEdgeBean> left_edge) { |
| | | this.left_edge = left_edge; |
| | | } |
| | | |
| | | public List<RightEdgeBean> getRight_edge() { |
| | | return right_edge; |
| | | } |
| | | |
| | | public void setRight_edge(List<RightEdgeBean> right_edge) { |
| | | this.right_edge = right_edge; |
| | | } |
| | | |
| | | public List<SeparateBean> getSeparate() { |
| | | return separate; |
| | | } |
| | | |
| | | public void setSeparate(List<SeparateBean> separate) { |
| | | this.separate = separate; |
| | | } |
| | | |
| | | public List<Integer> getStart_line() { |
| | | return start_line; |
| | | } |
| | | |
| | | public void setStart_line(List<Integer> start_line) { |
| | | this.start_line = start_line; |
| | | } |
| | | |
| | | public static class CrossingBean { |
| | | /** |
| | | * active : 2 |
| | | * center_point : 55 |
| | | * line : [26,140] |
| | | * stop_flag : 0 |
| | | * tts : 路口左转弯 |
| | | */ |
| | | |
| | | private int active; |
| | | private int center_point; |
| | | private int stop_flag; |
| | | private String tts; |
| | | private List<Integer> line; |
| | | |
| | | public int getActive() { |
| | | return active; |
| | | } |
| | | |
| | | public void setActive(int active) { |
| | | this.active = active; |
| | | } |
| | | |
| | | public int getCenter_point() { |
| | | return center_point; |
| | | } |
| | | |
| | | public void setCenter_point(int center_point) { |
| | | this.center_point = center_point; |
| | | } |
| | | |
| | | public int getStop_flag() { |
| | | return stop_flag; |
| | | } |
| | | |
| | | public void setStop_flag(int stop_flag) { |
| | | this.stop_flag = stop_flag; |
| | | } |
| | | |
| | | public String getTts() { |
| | | return tts; |
| | | } |
| | | |
| | | public void setTts(String tts) { |
| | | this.tts = tts; |
| | | } |
| | | |
| | | public List<Integer> getLine() { |
| | | return line; |
| | | } |
| | | |
| | | public void setLine(List<Integer> line) { |
| | | this.line = line; |
| | | } |
| | | } |
| | | |
| | | public static class LeftEdgeBean { |
| | | /** |
| | | * line : [352,353,354,355,356,357,358,359,360,361,362,363,364] |
| | | * type : 1 |
| | | */ |
| | | |
| | | private int type; |
| | | private List<Integer> line; |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public List<Integer> getLine() { |
| | | return line; |
| | | } |
| | | |
| | | public void setLine(List<Integer> line) { |
| | | this.line = line; |
| | | } |
| | | } |
| | | |
| | | public static class RightEdgeBean { |
| | | /** |
| | | * line : [333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351] |
| | | * type : 1 |
| | | */ |
| | | |
| | | private int type; |
| | | private List<Integer> line; |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public List<Integer> getLine() { |
| | | return line; |
| | | } |
| | | |
| | | public void setLine(List<Integer> line) { |
| | | this.line = line; |
| | | } |
| | | } |
| | | |
| | | public static class SeparateBean { |
| | | private List<LaneGuideBean> lane_guide; |
| | | private List<List<LaneLineBean>> lane_line; |
| | | |
| | | public List<LaneGuideBean> getLane_guide() { |
| | | return lane_guide; |
| | | } |
| | | |
| | | public void setLane_guide(List<LaneGuideBean> lane_guide) { |
| | | this.lane_guide = lane_guide; |
| | | } |
| | | |
| | | public List<List<LaneLineBean>> getLane_line() { |
| | | return lane_line; |
| | | } |
| | | |
| | | public void setLane_line(List<List<LaneLineBean>> lane_line) { |
| | | this.lane_line = lane_line; |
| | | } |
| | | |
| | | public static class LaneGuideBean { |
| | | private List<Integer> guide; |
| | | private List<Integer> head_tail; |
| | | |
| | | public List<Integer> getGuide() { |
| | | return guide; |
| | | } |
| | | |
| | | public void setGuide(List<Integer> guide) { |
| | | this.guide = guide; |
| | | } |
| | | |
| | | public List<Integer> getHead_tail() { |
| | | return head_tail; |
| | | } |
| | | |
| | | public void setHead_tail(List<Integer> head_tail) { |
| | | this.head_tail = head_tail; |
| | | } |
| | | } |
| | | |
| | | public static class LaneLineBean { |
| | | /** |
| | | * line : [365,366,367,368,369,370,371,372,373,374,375,376,377,378,379] |
| | | * type : 0 |
| | | */ |
| | | |
| | | private int type; |
| | | private List<Integer> line; |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public List<Integer> getLine() { |
| | | return line; |
| | | } |
| | | |
| | | public void setLine(List<Integer> line) { |
| | | this.line = line; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public static class SpecialAreaBean { |
| | | /** |
| | | * area : [39,40] |
| | | * id : 0 |
| | | * road : 2 |
| | | * type : 0 |
| | | */ |
| | | |
| | | private int id; |
| | | private int road; |
| | | private int type; |
| | | private List<Integer> area; |
| | | |
| | | public int getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(int id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public int getRoad() { |
| | | return road; |
| | | } |
| | | |
| | | public void setRoad(int road) { |
| | | this.road = road; |
| | | } |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public List<Integer> getArea() { |
| | | return area; |
| | | } |
| | | |
| | | public void setArea(List<Integer> area) { |
| | | this.area = area; |
| | | } |
| | | } |
| | | |
| | | public static class TriggerLineBean { |
| | | /** |
| | | * id : 0 |
| | | * line : [287] |
| | | * road : 5 |
| | | * tts : 变更车道 |
| | | * type : 1 |
| | | */ |
| | | |
| | | private int id; |
| | | private int road; |
| | | private String tts; |
| | | private int type; |
| | | private List<Integer> line; |
| | | |
| | | public int getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(int id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public int getRoad() { |
| | | return road; |
| | | } |
| | | |
| | | public void setRoad(int road) { |
| | | this.road = road; |
| | | } |
| | | |
| | | public String getTts() { |
| | | return tts; |
| | | } |
| | | |
| | | public void setTts(String tts) { |
| | | this.tts = tts; |
| | | } |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public List<Integer> getLine() { |
| | | return line; |
| | | } |
| | | |
| | | public void setLine(List<Integer> line) { |
| | | this.line = line; |
| | | } |
| | | } |
| | | } |
| | |
| | | switch (v.getId()){ |
| | | case R.id.btn_change_map: |
| | | if (ExamPlatformData.getInstance().getExamType()>ExamPlatformData.EXAM_TYPE_ChangKAO){ |
| | | RoadDriveMapFragmentaa jiaXiaoFragment = findFragment(RoadDriveMapFragmentaa.class); |
| | | RoadDriveMapFragmentab jiaXiaoFragment = findFragment(RoadDriveMapFragmentab.class); |
| | | if (jiaXiaoFragment == null) { |
| | | jiaXiaoFragment = (RoadDriveMapFragmentaa) RoadDriveMapFragmentaa.newInstance(); |
| | | jiaXiaoFragment = (RoadDriveMapFragmentab) RoadDriveMapFragmentab.newInstance(); |
| | | } |
| | | startWithPop(jiaXiaoFragment); |
| | | }else{ |
New file |
| | |
| | | package safeluck.drive.evaluation.fragment; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.BitmapFactory; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Color; |
| | | import android.graphics.DashPathEffect; |
| | | import android.graphics.Matrix; |
| | | import android.graphics.Paint; |
| | | import android.graphics.Path; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.SurfaceHolder; |
| | | import android.view.SurfaceView; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.Toast; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.appcompat.widget.Toolbar; |
| | | |
| | | import com.anyun.basecommonlib.MyLog; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.io.InputStream; |
| | | import java.lang.reflect.Type; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.LinkedBlockingQueue; |
| | | import java.util.concurrent.ScheduledExecutorService; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import me.yokeyword.fragmentation.SupportFragment; |
| | | import safeluck.drive.evaluation.Constant; |
| | | import safeluck.drive.evaluation.R; |
| | | import safeluck.drive.evaluation.bean.ExamPlatformData; |
| | | import safeluck.drive.evaluation.bean.RealTimeCarPos; |
| | | import safeluck.drive.evaluation.bean.RoadExamMap; |
| | | import safeluck.drive.evaluation.bean.RoadExamMap2; |
| | | import safeluck.drive.evaluation.bean.RoadExamMap3; |
| | | import safeluck.drive.evaluation.cEventCenter.CEventCenter; |
| | | import safeluck.drive.evaluation.cEventCenter.ICEventListener; |
| | | import safeluck.drive.evaluation.util.FileUtil; |
| | | import safeluck.drive.evaluation.util.Utils; |
| | | |
| | | public class RoadDriveMapFragmentab extends SupportFragment implements View.OnClickListener { |
| | | |
| | | private static final int ALL_MAP = 100; |
| | | private int pixels = 3; |
| | | private boolean isDrawing = false; |
| | | private StringBuffer buffer = null;//存放地图的buffer |
| | | |
| | | private ICEventListener speedListener = new ICEventListener() { |
| | | @Override |
| | | public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { |
| | | if (msgCode == Constant.RTK_INFO){ |
| | | gpsSpeed = (double)obj; |
| | | } |
| | | if (msgCode == Constant.LEFT_RIGHT_DISTANCE){ |
| | | String str = (String)obj; |
| | | |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(str); |
| | | leftDistance = Utils.getdouble(jsonObject.getDouble("left"),3); |
| | | rightDistance = Utils.getdouble(jsonObject.getDouble("right"),3); |
| | | |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | private double leftDistance =0.0; |
| | | private double rightDistance =0.0; |
| | | |
| | | public static SupportFragment newInstance() { |
| | | return new RoadDriveMapFragmentab(); |
| | | } |
| | | |
| | | private SurfaceView mSurfaceView; |
| | | private static final String TAG = "RoadDriveFragmentaa"; |
| | | private SurfaceHolder holder; |
| | | Path path = new Path(); |
| | | private Canvas canvas; |
| | | private int x = -1; |
| | | private int y = -1; |
| | | private Toolbar toolbar; |
| | | |
| | | private Bitmap bmp = null; |
| | | private Bitmap bmp2 = null; |
| | | private Canvas canvas2 = null; |
| | | private Canvas canvas3 = null; |
| | | private Paint paint = null; |
| | | private int screen_width = 0, screen_height = 0; |
| | | private String osdHeading = null; |
| | | private String osdMoveDirect = null; |
| | | private String osdRtkSpeed = null; |
| | | private String osdQf = null; |
| | | |
| | | private int map_id; |
| | | private double gpsSpeed = 0; |
| | | |
| | | double map[][] = {{-2.4065, 30.7090}, {-3.0759, 30.3599}, { -2.6023, 29.2578}, {-3.3316,28.9383},{-3.8247,30.0293}, |
| | | {-3.4503,30.1946}, {-2.9669,29.0981}, { -3.6962, 28.7786}, {-4.1991, 29.8640}}; |
| | | |
| | | // double map[][] ; |
| | | double car[][] = {{8.278, 1.467}, {7.2780000000000009, 1.467}, {7.2780000000000009, -1.533}, {8.278, -1.533} |
| | | , {9.278, -1.5330000000000004}, {9.277999999999999, 1.467000000000001}}; |
| | | Gson gson; |
| | | private LinkedBlockingQueue queue = new LinkedBlockingQueue(100); |
| | | private ExecutorService producer = Executors.newSingleThreadExecutor(); |
| | | private ExecutorService consumer = Executors.newSingleThreadExecutor(); |
| | | private long count =0; |
| | | private long lastcount =0; |
| | | private ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); |
| | | @Nullable |
| | | @Override |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | View view = inflater.inflate(R.layout.layout_mapfragment, container, false); |
| | | gson = new Gson(); |
| | | initView(view); |
| | | consumer.execute(new CalRunnable()); |
| | | scheduledExecutorService.scheduleAtFixedRate(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Log.i(TAG,"1s到"); |
| | | if (lastcount==count){ |
| | | Log.i(TAG,"已经没在发消息了"); |
| | | leftDistance = 0.0; |
| | | rightDistance = 0.0; |
| | | } |
| | | lastcount = count; |
| | | } |
| | | },1000,1000, TimeUnit.MILLISECONDS); |
| | | return view; |
| | | } |
| | | private int avaliableHeight,avalibleWidth; |
| | | private void initView(View view) { |
| | | |
| | | avaliableHeight= getResources().getDisplayMetrics().heightPixels; |
| | | avalibleWidth = getResources().getDisplayMetrics().widthPixels; |
| | | Log.i(TAG, "initView: aliwidht="+avalibleWidth+" height="+avaliableHeight); |
| | | mSurfaceView = view.findViewById(R.id.surfaceview); |
| | | view.findViewById(R.id.btn_reduce).setOnClickListener(this); |
| | | view.findViewById(R.id.btn_amplify).setOnClickListener(this); |
| | | holder = mSurfaceView.getHolder(); |
| | | |
| | | holder.addCallback(new SurfaceHolder.Callback() { |
| | | @Override |
| | | public void surfaceCreated(SurfaceHolder surfaceHolder) { |
| | | Canvas canvas = surfaceHolder.lockCanvas(); |
| | | |
| | | if (canvas != null) { |
| | | Log.d(TAG, "W = " + canvas.getWidth() + " H = " + canvas.getHeight()); |
| | | screen_width = canvas.getWidth(); |
| | | screen_height = canvas.getHeight(); |
| | | surfaceHolder.unlockCanvasAndPost(canvas); |
| | | |
| | | bmp = Bitmap.createBitmap(screen_width*2/3, screen_height, Bitmap.Config.ARGB_8888); |
| | | canvas2 = new Canvas(bmp); |
| | | canvas2.drawColor(Color.WHITE); |
| | | |
| | | |
| | | bmp2 = Bitmap.createBitmap(screen_width/3, screen_height, Bitmap.Config.ARGB_8888); |
| | | canvas3 = new Canvas(bmp2); |
| | | canvas3.drawColor(Color.WHITE); |
| | | |
| | | paint = new Paint(); |
| | | |
| | | paint.setTextSize(30); |
| | | paint.setColor(Color.BLACK); |
| | | paint.setStrokeWidth(1.5f); |
| | | paint.setAntiAlias(true); |
| | | paint.setStyle(Paint.Style.STROKE); |
| | | |
| | | holder.lockCanvas(); |
| | | canvas.drawBitmap(bmp, 0, 0, paint); |
| | | canvas.drawBitmap(bmp2, screen_width/3, 0, paint); |
| | | holder.unlockCanvasAndPost(canvas); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void surfaceDestroyed(SurfaceHolder surfaceHolder) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | class PointF { |
| | | double x; |
| | | double y; |
| | | |
| | | public PointF(double x, double y) { |
| | | this.x = x; |
| | | this.y = y; |
| | | } |
| | | |
| | | double getX() { |
| | | return x; |
| | | } |
| | | |
| | | double getY() { |
| | | return y; |
| | | } |
| | | |
| | | void setX(double x) { |
| | | this.x = x; |
| | | } |
| | | |
| | | void setY(double y) { |
| | | this.y = y; |
| | | } |
| | | } |
| | | |
| | | class Line { |
| | | double X1; |
| | | double Y1; |
| | | double X2; |
| | | double Y2; |
| | | |
| | | public Line(double x1, double y1, double x2, double y2) { |
| | | this.X1 = x1; |
| | | this.Y1 = y1; |
| | | this.X2 = x2; |
| | | this.Y2 = y2; |
| | | } |
| | | } |
| | | |
| | | private enum Relation { |
| | | GM_None, |
| | | GM_Tangent, |
| | | GM_Intersection, |
| | | GM_Containment |
| | | }; |
| | | |
| | | public PointF rotatePoint(PointF oldPoint, PointF centre, double degree) { |
| | | PointF newPoint = new PointF(0, 0); |
| | | |
| | | newPoint.setX( (oldPoint.getX()-centre.getX())*Math.cos(Math.toRadians(degree)) - (oldPoint.getY()-centre.getY())*Math.sin(Math.toRadians(degree)) + centre.getX() ); |
| | | newPoint.setY ( (oldPoint.getX()-centre.getX())*Math.sin(Math.toRadians(degree)) + (oldPoint.getY()-centre.getY())*Math.cos(Math.toRadians(degree)) + centre.getY() ); |
| | | |
| | | return newPoint; |
| | | } |
| | | |
| | | boolean isEqual(double a, double b) |
| | | { |
| | | return (Math.abs(a - b) <= 1e-6); |
| | | } |
| | | |
| | | Relation IntersectionOf(Line line1, Line line2) |
| | | { |
| | | if ((isEqual(line1.X1, line1.X2) && isEqual(line1.Y1, line1.Y2)) || (isEqual(line2.X1, line2.X2) && isEqual(line2.Y1, line2.Y2))) |
| | | return Relation.GM_None; |
| | | |
| | | if ((isEqual(line1.X1, line2.X1) && isEqual(line1.Y1, line2.Y1)) || (isEqual(line1.X2, line2.X1) && isEqual(line1.Y2, line2.Y1))) |
| | | return Relation.GM_Intersection; |
| | | |
| | | if ((isEqual(line1.X1, line2.X2) && isEqual(line1.Y1, line2.Y2)) || (isEqual(line1.X2, line2.X2) && isEqual(line1.Y2, line2.Y2))) |
| | | return Relation.GM_Intersection; |
| | | |
| | | line1.X2 -= line1.X1; line1.Y2 -= line1.Y1; |
| | | line2.X1 -= line1.X1; line2.Y1 -= line1.Y1; |
| | | line2.X2 -= line1.X1; line2.Y2 -= line1.Y1; |
| | | |
| | | double distAB = Math.sqrt(line1.X2 * line1.X2 + line1.Y2 * line1.Y2); |
| | | |
| | | double theCos = line1.X2 / distAB; |
| | | double theSin = line1.Y2 / distAB; |
| | | double newX = line2.X1 * theCos + line2.Y1 * theSin; |
| | | |
| | | line2.Y1 = line2.Y1 * theCos - line2.X1 * theSin; |
| | | line2.X1 = newX; |
| | | newX = line2.X2 * theCos + line2.Y2 * theSin; |
| | | line2.Y2 = line2.Y2 * theCos - line2.X2 * theSin; |
| | | line2.X2 = newX; |
| | | |
| | | if ((line2.Y1 < 0 && line2.Y2 < 0) || (line2.Y1 >= 0 && line2.Y2 >= 0)) { |
| | | return Relation.GM_None; |
| | | } |
| | | |
| | | double posAB = line2.X2 + (line2.X1 - line2.X2) * line2.Y2 / (line2.Y2 - line2.Y1); |
| | | |
| | | if (posAB < 0 || posAB > distAB) { |
| | | return Relation.GM_None; |
| | | } |
| | | |
| | | return Relation.GM_Intersection; |
| | | } |
| | | |
| | | Relation IntersectionOf(Line line, double screen_w, double screen_h) |
| | | { |
| | | boolean tangent = false; |
| | | |
| | | Line line1 = new Line(0, 0, screen_w, 0); |
| | | Line line2 = new Line(screen_w, 0, screen_w, screen_h); |
| | | Line line3 = new Line(screen_w, screen_h, 0, screen_h); |
| | | Line line4 = new Line(0, screen_h, 0, 0); |
| | | |
| | | Relation relation = IntersectionOf(line, line1); |
| | | if (relation == Relation.GM_Intersection) { |
| | | return relation; |
| | | } |
| | | if (relation == Relation.GM_Tangent) { |
| | | tangent = true; |
| | | } |
| | | |
| | | relation = IntersectionOf(line, line2); |
| | | if (relation == Relation.GM_Intersection) { |
| | | return relation; |
| | | } |
| | | if (relation == Relation.GM_Tangent) { |
| | | tangent = true; |
| | | } |
| | | |
| | | relation = IntersectionOf(line, line3); |
| | | if (relation == Relation.GM_Intersection) { |
| | | return relation; |
| | | } |
| | | if (relation == Relation.GM_Tangent) { |
| | | tangent = true; |
| | | } |
| | | |
| | | relation = IntersectionOf(line, line4); |
| | | if (relation == Relation.GM_Intersection) { |
| | | return relation; |
| | | } |
| | | if (relation == Relation.GM_Tangent) { |
| | | tangent = true; |
| | | } |
| | | |
| | | if (tangent) |
| | | return Relation.GM_Tangent; |
| | | |
| | | if (line.X1 > 0 && line.X1 < screen_w && line.Y1 > 0 && line.Y1 < screen_h) |
| | | return Relation.GM_Containment; |
| | | |
| | | return Relation.GM_None; |
| | | } |
| | | |
| | | static int angg = 0; |
| | | |
| | | public void DrawMap(double yaw, List<Double> mainAnt, double[][] map, double[][] car, |
| | | List<Integer>body, List<Integer> tire, List<RoadExamMap.MapsBean> maps) { |
| | | if (canvas2 == null || bmp == null) { |
| | | return; |
| | | } |
| | | float base_x = 300, base_y = 20; |
| | | double max_x = 0, min_x = 0, max_y = 0, min_y = 0; |
| | | long scale_x, scale_y; |
| | | |
| | | Log.d(TAG, "DrawMap map size " + map.length + " car size " + car.length); |
| | | |
| | | PointF mainPoint = new PointF(mainAnt.get(0), mainAnt.get(1)); |
| | | |
| | | Log.d(TAG, String.format("主天线 X = %f Y = %f 旋转角度 %f", mainPoint.getX(), mainPoint.getY(), yaw)); |
| | | |
| | | |
| | | |
| | | for (int x = 0; x < map.length; x++) { |
| | | PointF oldPoint = new PointF(map[x][0], map[x][1]); |
| | | PointF newPoint = oldPoint;//rotatePoint(oldPoint, mainPoint, yaw ); |
| | | map[x][0] = newPoint.getX(); |
| | | map[x][1] = newPoint.getY(); |
| | | |
| | | map[x][0] = map[x][0] - mainPoint.getX(); |
| | | map[x][1] = map[x][1] - mainPoint.getY(); |
| | | map[x][1] = -map[x][1]; |
| | | } |
| | | |
| | | for (int i = 0; i < car.length; i++) { |
| | | PointF oldPoint = new PointF(car[i][0], car[i][1]); |
| | | PointF newPoint = oldPoint;//rotatePoint(oldPoint, mainPoint, yaw ); |
| | | car[i][0] = newPoint.getX(); |
| | | car[i][1] = newPoint.getY(); |
| | | |
| | | car[i][0] = car[i][0] - mainPoint.getX(); |
| | | car[i][1] = car[i][1] - mainPoint.getY(); |
| | | car[i][1] = -car[i][1]; |
| | | } |
| | | |
| | | scale_x = Math.round(Math.abs(pixels / Math.sqrt(Math.pow(car[0][0], 2) + Math.pow(car[0][1], 2)) )); |
| | | scale_y = scale_x; |
| | | |
| | | base_x = bmp.getWidth() / 2; |
| | | base_y = bmp.getHeight() * 7 / 10; |
| | | |
| | | Log.d(TAG, String.format("DrawMapAll scale_x = %d 车头据 = %f", scale_x, Math.sqrt(Math.pow(car[0][0], 2) + Math.pow(car[0][1], 2)))); |
| | | |
| | | |
| | | /* |
| | | for (int i = 0; i < map.length; i++) { |
| | | if (i == 0) { |
| | | max_x = map[0][0]; |
| | | min_x = map[0][0]; |
| | | max_y = map[0][1]; |
| | | min_y = map[0][1]; |
| | | } else { |
| | | if (max_x < map[i][0]) { |
| | | max_x = map[i][0]; |
| | | } |
| | | if (min_x > map[i][0]) { |
| | | min_x = map[i][0]; |
| | | } |
| | | if (max_y < map[i][1]) { |
| | | max_y = map[i][1]; |
| | | } |
| | | if (min_y > map[i][1]) { |
| | | min_y = map[i][1]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | Log.d(TAG, "DrawMap max_x " + max_x + " max_y " + max_y + " min_x " + min_x + " min_y " + min_y); |
| | | |
| | | for (int i = 0; i < car.length; i++) { |
| | | if (max_x < car[i][0]) { |
| | | max_x = car[i][0]; |
| | | } |
| | | if (min_x > car[i][0]) { |
| | | min_x = car[i][0]; |
| | | } |
| | | if (max_y < car[i][1]) { |
| | | max_y = car[i][1]; |
| | | } |
| | | if (min_y > car[i][1]) { |
| | | min_y = car[i][1]; |
| | | } |
| | | } |
| | | |
| | | Log.d(TAG, "DrawMap max_x " + max_x + " max_y " + max_y + " min_x " + min_x + " min_y " + min_y); |
| | | |
| | | Log.i(TAG,String.format("screen_width - base_x - 10=%f,screen_height - base_y - 10=%f,max_x - min_x=%f,max_y - min_y=%f",screen_width - base_x - 10,screen_height - base_y - 10 |
| | | ,max_x - min_x,max_y - min_y)); |
| | | |
| | | |
| | | long scale_x = Math.round((screen_width - base_x - 10) / (max_x - min_x)); |
| | | long scale_y = Math.round((screen_height - base_y - 10) / (max_y - min_y)); |
| | | |
| | | Log.i(TAG,String.format("scale_x=%d,scale_y=%d",scale_x,scale_y)); |
| | | |
| | | if (scale_x >= scale_y) { |
| | | scale_x = scale_y; |
| | | } else { |
| | | scale_y = scale_x; |
| | | } |
| | | |
| | | Log.d(TAG, "DrawMap scale_x " + scale_x + " scale_y " + scale_y); |
| | | */ |
| | | canvas2.drawColor(Color.WHITE); |
| | | |
| | | if (paint == null || canvas2==null){ |
| | | return; |
| | | } |
| | | paint.setStyle(Paint.Style.FILL_AND_STROKE); |
| | | paint.setColor(Color.BLUE); |
| | | |
| | | canvas2.drawCircle((float) (base_x), (float) (base_y), 2, paint); |
| | | |
| | | paint.setColor(Color.RED); |
| | | canvas2.drawCircle((float) (base_x + (car[tire.get(0)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(0)][1] - min_y) * scale_y), 2.5f, paint); |
| | | canvas2.drawCircle((float) (base_x + (car[tire.get(1)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(1)][1] - min_y) * scale_y), 2.5f, paint); |
| | | canvas2.drawCircle((float) (base_x + (car[tire.get(2)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(2)][1] - min_y) * scale_y), 2.5f, paint); |
| | | canvas2.drawCircle((float) (base_x + (car[tire.get(3)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(3)][1] - min_y) * scale_y), 2.5f, paint); |
| | | |
| | | paint.setStyle(Paint.Style.STROKE); |
| | | paint.setColor(Color.BLACK); |
| | | |
| | | Path path = new Path(); |
| | | Log.i(TAG, "DrawMap: map.length:"+map.length); |
| | | if (maps != null&& maps.size()>0){ |
| | | for (int i = 0; i < maps.size(); i++) { |
| | | RoadExamMap.MapsBean mapItem = maps.get(i); |
| | | |
| | | if (mapItem.getItem() == ALL_MAP){ |
| | | List<List<Integer>> redLines= mapItem.getRed_line(); |
| | | List<List<Integer>> greenLines = mapItem.getGreen_line(); |
| | | List<List<Integer>> allTringgerLines = mapItem.getAll_trigger_line(); |
| | | |
| | | |
| | | for (List<Integer> allTriggerLine: allTringgerLines |
| | | ) { |
| | | for (int kk = 1; kk < allTriggerLine.size(); kk++) { |
| | | int pos = allTriggerLine.get(kk); |
| | | if (kk ==1){ |
| | | path.moveTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); |
| | | } |
| | | path.lineTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); |
| | | Log.i(TAG,String.format("trigerline map[%d][0]=%f,map[%d][1]=%f,line to (%f,%f)",pos,map[pos][0],pos,map[pos][1], |
| | | (float) (base_x + (map[pos][0] - min_x) * scale_x),(float) (base_y + (map[pos][1] - min_y) * scale_y))); |
| | | } |
| | | } |
| | | |
| | | paint.reset(); |
| | | paint.setStyle(Paint.Style.STROKE); |
| | | paint.setStrokeWidth(1.5f); |
| | | paint.setAntiAlias(true); |
| | | paint.setColor(Color.RED); |
| | | |
| | | Log.i(TAG,"redLinesSize"+redLines.size()); |
| | | for (List<Integer> redline: redLines |
| | | ) { |
| | | for (int j = 0; j < redline.size(); j++) { |
| | | Log.i(TAG,"redLiSize"+redline.size()); |
| | | int pos = redline.get(j); |
| | | if (j == 0){ |
| | | path.moveTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); |
| | | } |
| | | path.lineTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); |
| | | Log.i(TAG,String.format("map[%d][0]=%f,map[%d][1]=%f,line to (%f,%f)",pos,map[pos][0],pos,map[pos][1], |
| | | (float) (base_x + (map[pos][0] - min_x) * scale_x),(float) (base_y + (map[pos][1] - min_y) * scale_y))); |
| | | |
| | | } |
| | | } |
| | | canvas2.drawPath(path,paint); |
| | | //画虚线(分道线) |
| | | |
| | | Paint paintFenDao = new Paint(Paint.ANTI_ALIAS_FLAG); |
| | | Path pathFenDao = new Path(); |
| | | paintFenDao.reset(); |
| | | paintFenDao.setStyle(Paint.Style.STROKE); |
| | | paintFenDao.setStrokeWidth(1.5f); |
| | | paintFenDao.setAntiAlias(true); |
| | | paintFenDao.setPathEffect(new DashPathEffect(new float[] {15, 15}, 0)); |
| | | for (List<Integer> greenline: |
| | | greenLines){ |
| | | for (int j = 0; j < greenline.size(); j++) { |
| | | int pos = greenline.get(j); |
| | | if (j == 0){ |
| | | pathFenDao.moveTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); |
| | | } |
| | | pathFenDao.lineTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); |
| | | Log.i(TAG,String.format("map[%d][0]=%f,map[%d][1]=%f,line to (%f,%f)",pos,map[pos][0],pos,map[pos][1], |
| | | (float) (base_x + (map[pos][0] - min_x) * scale_x),(float) (base_y + (map[pos][1] - min_y) * scale_y))); |
| | | } |
| | | } |
| | | canvas2.drawPath(pathFenDao,paintFenDao); |
| | | |
| | | }else{ |
| | | List<Integer> area = mapItem.getArea(); |
| | | List<Integer> stoplines = mapItem.getStop_line(); |
| | | for (int aaa = 0; aaa <stoplines.size(); aaa++) { |
| | | |
| | | int pos = stoplines.get(aaa); |
| | | if (aaa==0){ |
| | | path.moveTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); |
| | | }else{ |
| | | path.lineTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); |
| | | } |
| | | canvas2.drawPath(path,paint); |
| | | } |
| | | for (int jj = 0; jj < area.size(); jj++) { |
| | | int pos = area.get(jj); |
| | | if (jj==0){ |
| | | path.moveTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); |
| | | }else{ |
| | | path.lineTo((float) (base_x + (map[pos][0] - min_x) * scale_x), (float) (base_y + (map[pos][1] - min_y) * scale_y)); |
| | | } |
| | | } |
| | | path.close(); |
| | | canvas2.drawPath(path,paint); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | /*Bitmap bmpp = readBitmapById(R.drawable.police_car); |
| | | |
| | | double min_body_x, max_body_x, min_body_y, max_body_y; |
| | | |
| | | max_body_x = min_body_x = car[body.get(0)][0]; |
| | | min_body_y = max_body_y = car[body.get(0)][1]; |
| | | for (int i = 1; i < body.size(); i++){ |
| | | if (max_body_x < car[body.get(i)][0]) { |
| | | max_body_x = car[body.get(i)][0]; |
| | | } |
| | | if (min_body_x > car[body.get(i)][0]) { |
| | | min_body_x = car[body.get(i)][0]; |
| | | } |
| | | if (max_body_y < car[body.get(i)][1]) { |
| | | max_body_y = car[body.get(i)][1]; |
| | | } |
| | | if (min_body_y > car[body.get(i)][1]) { |
| | | min_body_y = car[body.get(i)][1]; |
| | | } |
| | | } |
| | | |
| | | |
| | | bmpp = scaleImage(bmpp, (int)((max_body_x - min_body_x)*scale_x), (int)((max_body_y - min_body_y)*scale_y)); |
| | | |
| | | Log.d(TAG, "图片尺寸 " + bmpp.getWidth() + " " + bmpp.getHeight()); |
| | | |
| | | canvas2.drawBitmap(bmpp, 0, 0, paint); |
| | | |
| | | bmpp = rotaingImageView(angg, bmpp); |
| | | |
| | | Log.d(TAG, String.valueOf(angg) + " 旋转后的 图片尺寸 " + bmpp.getWidth() + " " + bmpp.getHeight()); |
| | | |
| | | angg += 10; |
| | | |
| | | if (angg == 360) angg = 0; |
| | | |
| | | canvas2.drawBitmap(bmpp, 300, 200, paint);*/ |
| | | |
| | | // canvas2.drawPath(path, paint); |
| | | paint.setColor(Color.BLACK); |
| | | path.moveTo((float) (base_x + (car[body.get(0)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(0)][1] - min_y) * scale_y)); |
| | | for (int i = 1; i < body.size(); i++){ |
| | | // Log.d(TAG, "for 循环 DrawMap to X = " + (float) (base_x + (car[body.get(i)][0] - min_x) * scale_x)+ " Y = " + (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y)); |
| | | path.lineTo((float) (base_x + (car[body.get(i)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y)); |
| | | } |
| | | |
| | | path.close(); |
| | | |
| | | canvas2.drawPath(path, paint); |
| | | |
| | | paint.setStyle(Paint.Style.FILL_AND_STROKE); |
| | | paint.setPathEffect(null); |
| | | paint.setColor(Color.BLACK); |
| | | |
| | | paint.setStyle(Paint.Style.FILL_AND_STROKE); |
| | | |
| | | canvas3.drawColor(Color.YELLOW); |
| | | |
| | | // 指南针 ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| | | float compassOX = bmp2.getWidth() - 60, compassOY = 60; |
| | | |
| | | float compass1X = compassOX + 7, compass1Y = compassOY; |
| | | float compass2X = compassOX, compass2Y = compassOY + 30; |
| | | float compass3X = compassOX - 7, compass3Y = compassOY; |
| | | |
| | | float compass4X = compassOX + 7, compass4Y = compassOY; |
| | | float compass5X = compassOX, compass5Y = compassOY - 30; |
| | | float compass6X = compassOX - 7, compass6Y = compassOY; |
| | | |
| | | PointF compassO = new PointF(compassOX, compassOY); |
| | | PointF compass1 = new PointF(compass1X, compass1Y); |
| | | PointF compass2 = new PointF(compass2X, compass2Y); |
| | | PointF compass3 = new PointF(compass3X, compass3Y); |
| | | PointF compass4 = new PointF(compass4X, compass4Y); |
| | | PointF compass5 = new PointF(compass5X, compass5Y); |
| | | PointF compass6 = new PointF(compass6X, compass6Y); |
| | | |
| | | compass1 = rotatePoint(compass1, compassO, yaw); |
| | | compass2 = rotatePoint(compass2, compassO, yaw); |
| | | compass3 = rotatePoint(compass3, compassO, yaw); |
| | | compass4 = rotatePoint(compass4, compassO, yaw); |
| | | compass5 = rotatePoint(compass5, compassO, yaw); |
| | | compass6 = rotatePoint(compass6, compassO, yaw); |
| | | |
| | | paint.setStyle(Paint.Style.STROKE); |
| | | paint.setColor(Color.RED); |
| | | |
| | | canvas3.drawCircle((float)compassO.getX(), (float)compassO.getY(), 20, paint); |
| | | canvas3.drawCircle((float)compassO.getX(), (float)compassO.getY(), 40, paint); |
| | | |
| | | paint.setStyle(Paint.Style.FILL_AND_STROKE); |
| | | paint.setColor(Color.BLUE); |
| | | Path compassN = new Path(); |
| | | |
| | | compassN.moveTo((float)compassO.getX(), (float)compassO.getY()); |
| | | compassN.lineTo((float)compass1.getX(), (float)compass1.getY()); |
| | | compassN.lineTo((float)compass2.getX(), (float)compass2.getY()); |
| | | compassN.lineTo((float)compass3.getX(), (float)compass3.getY()); |
| | | compassN.close(); |
| | | canvas3.drawPath(compassN, paint); |
| | | |
| | | paint.setColor(Color.RED); |
| | | Path compassS = new Path(); |
| | | compassS.moveTo((float)compassO.getX(), (float)compassO.getY()); |
| | | compassS.lineTo((float)compass4.getX(), (float)compass4.getY()); |
| | | compassS.lineTo((float)compass5.getX(), (float)compass5.getY()); |
| | | compassS.lineTo((float)compass6.getX(), (float)compass6.getY()); |
| | | compassS.close(); |
| | | canvas3.drawPath(compassS, paint); |
| | | |
| | | // 指南针 ------------------------------------------- |
| | | |
| | | if (osdHeading != null) { |
| | | Path pathText = new Path(); |
| | | pathText.moveTo(10, 30); |
| | | pathText.lineTo(700, 30); |
| | | canvas3.drawTextOnPath(osdHeading, pathText, 0, 0, paint);//逆时针生成 |
| | | } |
| | | |
| | | // if (osdMoveDirect != null) { |
| | | // Path pathText = new Path(); |
| | | // pathText.moveTo(10, 30); |
| | | // pathText.lineTo(700, 30); |
| | | // canvas3.drawTextOnPath(osdMoveDirect, pathText, 0, 0, paint);//逆时针生成 |
| | | // } |
| | | |
| | | if (osdRtkSpeed != null) { |
| | | Path pathText = new Path(); |
| | | pathText.moveTo(10, 70); |
| | | pathText.lineTo(700, 70); |
| | | canvas3.drawTextOnPath(osdRtkSpeed, pathText, 0, 0, paint);//逆时针生成 |
| | | } |
| | | // |
| | | // if (osdQf != null) { |
| | | // Path pathText = new Path(); |
| | | // pathText.moveTo(10, 120); |
| | | // pathText.lineTo(700, 120); |
| | | // canvas3.drawTextOnPath(osdQf, pathText, 0, 0, paint);//逆时针生成 |
| | | // } |
| | | // |
| | | // { |
| | | // BigDecimal bd = new BigDecimal(gpsSpeed); |
| | | // bd = bd.setScale(3, BigDecimal.ROUND_HALF_UP); |
| | | // |
| | | // Path pathText = new Path(); |
| | | // pathText.moveTo(10, 70); |
| | | // pathText.lineTo(700, 70); |
| | | // |
| | | // canvas3.drawTextOnPath("GPS速度:" + bd, pathText, 0, 0, paint);//逆时针生成 |
| | | // } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | base_x = 170; |
| | | base_y = 350; |
| | | |
| | | scale_x=scale_y = 27; |
| | | |
| | | paint.setStyle(Paint.Style.FILL_AND_STROKE); |
| | | paint.setColor(Color.BLUE); |
| | | // canvas2.drawCircle((float) (base_x + (mainAnt.get(0) - min_x) * scale_x), (float) (base_y + (mainAnt.get(1) - min_y) * scale_y), 2, paint); |
| | | canvas3.drawCircle((float) base_x, (float) base_y, 2, paint); |
| | | |
| | | paint.setColor(Color.RED); |
| | | |
| | | canvas3.drawCircle((float) (base_x + (car[tire.get(0)][0]) * scale_x), (float) (base_y + (car[tire.get(0)][1]) * scale_y), 2.5f, paint); |
| | | canvas3.drawCircle((float) (base_x + (car[tire.get(1)][0]) * scale_x), (float) (base_y + (car[tire.get(1)][1]) * scale_y), 2.5f, paint); |
| | | canvas3.drawCircle((float) (base_x + (car[tire.get(2)][0]) * scale_x), (float) (base_y + (car[tire.get(2)][1]) * scale_y), 2.5f, paint); |
| | | canvas3.drawCircle((float) (base_x + (car[tire.get(3)][0]) * scale_x), (float) (base_y + (car[tire.get(3)][1]) * scale_y), 2.5f, paint); |
| | | |
| | | |
| | | Path pathCanvs3 = new Path(); |
| | | pathCanvs3.moveTo((float) (base_x + (car[body.get(0)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(0)][1] - min_y) * scale_y)); |
| | | for (int i = 1; i < body.size(); i++){ |
| | | // Log.d(TAG, "for 循环 DrawMap to X = " + (float) (base_x + (car[body.get(i)][0] - min_x) * scale_x)+ " Y = " + (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y)); |
| | | Log.i(TAG,String.format("car[%d][0]=%f,to X =%f,car[%d][1]=%f,to Y=%f",i,car[body.get(i)][0], |
| | | (float) (base_x + (car[body.get(i)][0] - min_x) * scale_x),i,car[body.get(i)][1],(float) (base_y + (car[body.get(i)][1] - min_y) * scale_y))); |
| | | pathCanvs3.lineTo((float) (base_x + (car[body.get(i)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y)); |
| | | } |
| | | paint.setStyle(Paint.Style.STROKE); |
| | | paint.setColor(Color.BLACK); |
| | | pathCanvs3.close(); |
| | | canvas3.drawPath(pathCanvs3,paint); |
| | | |
| | | Paint mPaint = new Paint(); |
| | | mPaint.setTextSize(20); |
| | | mPaint.setStyle(Paint.Style.FILL_AND_STROKE); |
| | | osdMoveDirect="9.4345"; |
| | | if (osdMoveDirect != null) { |
| | | Path pathText = new Path(); |
| | | pathText.moveTo(base_x-110, base_y-35); |
| | | pathText.lineTo(base_x-20, base_y-35); |
| | | if (leftDistance == 0.0){ |
| | | |
| | | canvas3.drawTextOnPath("...", pathText, 0, 0, mPaint);//逆时针生成 |
| | | }else{ |
| | | |
| | | canvas3.drawTextOnPath(String.valueOf(leftDistance), pathText, 0, 0, mPaint);//逆时针生成 |
| | | } |
| | | } |
| | | if (osdMoveDirect != null) { |
| | | Path pathText = new Path(); |
| | | pathText.moveTo(base_x+30, base_y-35); |
| | | pathText.lineTo(base_x+110, base_y-35); |
| | | if (rightDistance == 0.0){ |
| | | |
| | | canvas3.drawTextOnPath("...", pathText, 0, 0, mPaint);//逆时针生成 |
| | | }else{ |
| | | canvas3.drawTextOnPath(String.valueOf(rightDistance), pathText, 0, 0, mPaint);//逆时针生成 |
| | | } |
| | | } |
| | | paint.setColor(Color.RED); |
| | | canvas3.drawLine(base_x-120,base_y-200,base_x-120,base_y+200,paint); |
| | | canvas3.drawLine(base_x+120,base_y-200,base_x+120,base_y+200,paint); |
| | | |
| | | DrawArrows(canvas3,Color.GREEN,15f,base_x-20,base_y-30,base_x-120,base_y-30);//左边箭头(左边距 |
| | | DrawArrows(canvas3,Color.GREEN,15f,base_x+20,base_y-30,base_x+120,base_y-30);//右边箭头(边距 |
| | | |
| | | |
| | | |
| | | |
| | | // 提交画布 |
| | | Canvas canvas = holder.lockCanvas(); |
| | | if (canvas != null){ |
| | | |
| | | canvas.drawBitmap(bmp, 0, 0, paint); |
| | | canvas.drawBitmap(bmp2, screen_width*2/3, 0, paint); |
| | | holder.unlockCanvasAndPost(canvas); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void DrawMap2(double yaw, List<Double> mainAnt, double[][] map, double[][] car, |
| | | List<Integer>body, List<Integer> tire, List<RoadExamMap3.RoadBean> roadBeanList, |
| | | List<RoadExamMap3.SpecialAreaBean> specialAreaBeanList) { |
| | | if (canvas2 == null || bmp == null) { |
| | | return; |
| | | } |
| | | float base_x = 300, base_y = 20; |
| | | double max_x = 0, min_x = 0, max_y = 0, min_y = 0; |
| | | long scale_x, scale_y; |
| | | |
| | | Log.d(TAG, "DrawMap2 map size " + map.length + " car size " + car.length); |
| | | |
| | | PointF mainPoint = new PointF(mainAnt.get(0), mainAnt.get(1)); |
| | | |
| | | Log.d(TAG, String.format("主天线 X = %f Y = %f 旋转角度 %f", mainPoint.getX(), mainPoint.getY(), yaw)); |
| | | |
| | | |
| | | for (int x = 0; x < map.length; x++) { |
| | | PointF oldPoint = new PointF(map[x][0], map[x][1]); |
| | | PointF newPoint = rotatePoint(oldPoint, mainPoint, yaw ); |
| | | map[x][0] = newPoint.getX(); |
| | | map[x][1] = newPoint.getY(); |
| | | |
| | | map[x][0] = map[x][0] - mainPoint.getX(); |
| | | map[x][1] = map[x][1] - mainPoint.getY(); |
| | | map[x][1] = -map[x][1]; |
| | | } |
| | | |
| | | for (int i = 0; i < car.length; i++) { |
| | | PointF oldPoint = new PointF(car[i][0], car[i][1]); |
| | | PointF newPoint = rotatePoint(oldPoint, mainPoint, yaw ); |
| | | car[i][0] = newPoint.getX(); |
| | | car[i][1] = newPoint.getY(); |
| | | |
| | | car[i][0] = car[i][0] - mainPoint.getX(); |
| | | car[i][1] = car[i][1] - mainPoint.getY(); |
| | | car[i][1] = -car[i][1]; |
| | | } |
| | | |
| | | scale_x = Math.round(Math.abs(50 / Math.sqrt(Math.pow(car[0][0], 2) + Math.pow(car[0][1], 2)) )); |
| | | |
| | | scale_x = pixels; |
| | | |
| | | scale_y = scale_x; |
| | | |
| | | base_x = bmp.getWidth() / 2; |
| | | base_y = bmp.getHeight() * 7 / 10; |
| | | |
| | | Log.d(TAG, String.format("DrawMapAll scale_x = %d 车头据 = %f", scale_x, Math.sqrt(Math.pow(car[0][0], 2) + Math.pow(car[0][1], 2)))); |
| | | |
| | | canvas2.drawColor(Color.BLACK); |
| | | |
| | | // 画车轮 |
| | | paint.setStyle(Paint.Style.FILL_AND_STROKE); |
| | | paint.setColor(Color.BLUE); |
| | | |
| | | canvas2.drawCircle((float) (base_x), (float) (base_y), 2, paint); |
| | | |
| | | paint.setColor(Color.RED); |
| | | canvas2.drawCircle((float) (base_x + (car[tire.get(0)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(0)][1] - min_y) * scale_y), 2.5f, paint); |
| | | canvas2.drawCircle((float) (base_x + (car[tire.get(1)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(1)][1] - min_y) * scale_y), 2.5f, paint); |
| | | canvas2.drawCircle((float) (base_x + (car[tire.get(2)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(2)][1] - min_y) * scale_y), 2.5f, paint); |
| | | canvas2.drawCircle((float) (base_x + (car[tire.get(3)][0] - min_x) * scale_x), (float) (base_y + (car[tire.get(3)][1] - min_y) * scale_y), 2.5f, paint); |
| | | |
| | | paint.setStyle(Paint.Style.STROKE); |
| | | paint.setColor(Color.GREEN); |
| | | paint.setStrokeWidth(2.0f); |
| | | |
| | | Path carpath = new Path(); |
| | | // 画车体 |
| | | carpath.moveTo((float) (base_x + (car[body.get(0)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(0)][1] - min_y) * scale_y)); |
| | | for (int i = 1; i < body.size(); i++){ |
| | | // Log.d(TAG, "for 循环 DrawMap to X = " + (float) (base_x + (car[body.get(i)][0] - min_x) * scale_x)+ " Y = " + (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y)); |
| | | carpath.lineTo((float) (base_x + (car[body.get(i)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y)); |
| | | } |
| | | |
| | | carpath.close(); |
| | | |
| | | canvas2.drawPath(carpath, paint); |
| | | |
| | | Path path = new Path(); |
| | | |
| | | // 画地图 |
| | | if (roadBeanList != null) { |
| | | for (int x = 0; x < roadBeanList.size(); x++) { |
| | | RoadExamMap3.RoadBean road = roadBeanList.get(x); |
| | | Log.d(TAG, "路 id = "+ road.getId()); |
| | | |
| | | List<RoadExamMap3.RoadBean.LeftEdgeBean> leftEdge = road.getLeft_edge(); |
| | | |
| | | if (leftEdge != null) { |
| | | Log.d(TAG, "绘制左路沿"); |
| | | |
| | | paint.setStrokeWidth(3.0f); |
| | | paint.setColor(Color.YELLOW); |
| | | |
| | | for (int y = 0; y < leftEdge.size(); y++) { |
| | | RoadExamMap3.RoadBean.LeftEdgeBean edgeBean = leftEdge.get(y); |
| | | |
| | | if (edgeBean.getType() == 0) { |
| | | paint.setPathEffect(new DashPathEffect(new float[] {20, 20}, 0)); |
| | | } else { |
| | | paint.setPathEffect(new DashPathEffect(new float[] {10000, 0}, 0)); |
| | | } |
| | | |
| | | List<Integer> line = edgeBean.getLine(); |
| | | Log.d(TAG, "路边沿 " + y + " 分段 " + line.size()); |
| | | |
| | | int draw_status = 0; |
| | | |
| | | for (int z = 0; z < line.size() - 1; z++) { |
| | | float scr_x = (float) (base_x + (map[line.get(z)][0] - min_x) * scale_x); |
| | | float scr_y = (float) (base_y + (map[line.get(z)][1] - min_y) * scale_y); |
| | | |
| | | float scr_x2 = (float) (base_x + (map[line.get(z+1)][0] - min_x) * scale_x); |
| | | float scr_y2 = (float) (base_y + (map[line.get(z+1)][1] - min_y) * scale_y); |
| | | |
| | | Line linex = new Line(scr_x, scr_y, scr_x2, scr_y2); |
| | | |
| | | Relation relation = IntersectionOf(linex, bmp.getWidth(), bmp.getHeight()); |
| | | |
| | | if (relation == Relation.GM_Intersection || relation == Relation.GM_Containment) { |
| | | if (draw_status == 0) { |
| | | path.moveTo(scr_x, scr_y); |
| | | path.lineTo(scr_x2, scr_y2); |
| | | draw_status = 1; |
| | | } else if (draw_status == 1) { |
| | | path.lineTo(scr_x2, scr_y2); |
| | | } |
| | | } else if (draw_status == 1) { |
| | | canvas2.drawPath(path, paint); |
| | | draw_status = 0; |
| | | } |
| | | } |
| | | if (draw_status == 1) { |
| | | canvas2.drawPath(path, paint); |
| | | draw_status = 0; |
| | | } |
| | | |
| | | |
| | | // path.moveTo((float) (base_x + (map[line.get(0)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(0)][1] - min_y) * scale_y)); |
| | | // |
| | | // Log.d(TAG, String.format("0. X = %f Y = %f", map[line.get(0)][0], map[line.get(0)][1])); |
| | | // |
| | | // for (int z = 1; z < line.size(); z++) { |
| | | // path.lineTo((float) (base_x + (map[line.get(z)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(z)][1] - min_y) * scale_y)); |
| | | // Log.d(TAG, String.format("%d. X = %f Y = %f", z, map[line.get(z)][0], map[line.get(z)][1])); |
| | | // } |
| | | // Log.d(TAG, "路边沿......"); |
| | | // canvas2.drawPath(path, paint); |
| | | Log.d(TAG, "左路边沿完毕"); |
| | | } |
| | | } |
| | | |
| | | List<RoadExamMap3.RoadBean.RightEdgeBean> rightEdge = road.getRight_edge(); |
| | | |
| | | if (rightEdge != null) { |
| | | Log.d(TAG, "绘制右路沿"); |
| | | |
| | | paint.setStrokeWidth(3.0f); |
| | | paint.setColor(Color.YELLOW); |
| | | |
| | | for (int y = 0; y < rightEdge.size(); y++) { |
| | | RoadExamMap3.RoadBean.RightEdgeBean edgeBean = rightEdge.get(y); |
| | | |
| | | if (edgeBean.getType() == 0) { |
| | | Log.d(TAG, "虚线"); |
| | | paint.setPathEffect(new DashPathEffect(new float[] {20, 20}, 0)); |
| | | } else { |
| | | Log.d(TAG, "实线"); |
| | | paint.setPathEffect(new DashPathEffect(new float[] {10000, 0}, 0)); |
| | | } |
| | | |
| | | List<Integer> line = edgeBean.getLine(); |
| | | |
| | | Path edgePath = new Path(); |
| | | Log.d(TAG, "路边沿 " + y + " 分段 " + line.size()); |
| | | |
| | | int draw_status = 0; |
| | | |
| | | for (int z = 0; z < line.size()-1; z++) { |
| | | float scr_x = (float) (base_x + (map[line.get(z)][0] - min_x) * scale_x); |
| | | float scr_y = (float) (base_y + (map[line.get(z)][1] - min_y) * scale_y); |
| | | |
| | | float scr_x2 = (float) (base_x + (map[line.get(z+1)][0] - min_x) * scale_x); |
| | | float scr_y2 = (float) (base_y + (map[line.get(z+1)][1] - min_y) * scale_y); |
| | | |
| | | Line linex = new Line(scr_x, scr_y, scr_x2, scr_y2); |
| | | |
| | | Relation relation = IntersectionOf(linex, bmp.getWidth(), bmp.getHeight()); |
| | | |
| | | if (relation == Relation.GM_Intersection || relation == Relation.GM_Containment) { |
| | | if (draw_status == 0) { |
| | | edgePath.moveTo(scr_x, scr_y); |
| | | edgePath.lineTo(scr_x2, scr_y2); |
| | | draw_status = 1; |
| | | } else if (draw_status == 1) { |
| | | edgePath.lineTo(scr_x2, scr_y2); |
| | | } |
| | | } else if (draw_status == 1) { |
| | | canvas2.drawPath(edgePath, paint); |
| | | draw_status = 0; |
| | | } |
| | | } |
| | | if (draw_status == 1) { |
| | | canvas2.drawPath(edgePath, paint); |
| | | draw_status = 0; |
| | | } |
| | | |
| | | // edgePath.moveTo((float) (base_x + (map[line.get(0)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(0)][1] - min_y) * scale_y)); |
| | | // |
| | | // Log.d(TAG, String.format("0. X = %f Y = %f", map[line.get(0)][0], map[line.get(0)][1])); |
| | | // |
| | | // for (int z = 1; z < line.size(); z++) { |
| | | // edgePath.lineTo((float) (base_x + (map[line.get(z)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(z)][1] - min_y) * scale_y)); |
| | | // Log.d(TAG, String.format("%d. X = %f Y = %f", z, map[line.get(z)][0], map[line.get(z)][1])); |
| | | // } |
| | | // Log.d(TAG, "路边沿......"); |
| | | // canvas2.drawPath(edgePath, paint); |
| | | |
| | | Log.d(TAG, "右路边沿完毕"); |
| | | } |
| | | } |
| | | |
| | | List<RoadExamMap3.RoadBean.SeparateBean> separate = road.getSeparate(); |
| | | |
| | | paint.setStrokeWidth(2.0f); |
| | | paint.setColor(Color.WHITE); |
| | | |
| | | if (separate != null) { |
| | | Log.d(TAG, "绘制道路分割线 段数量 = " + separate.size()); |
| | | |
| | | |
| | | for (int y = 0; y < separate.size(); y++) { |
| | | List<List<RoadExamMap3.RoadBean.SeparateBean.LaneLineBean>> lines = separate.get(y).getLane_line(); |
| | | |
| | | Log.d(TAG, "线数量 = " + lines.size()); |
| | | |
| | | for (int z = 0; z < lines.size(); z++) { |
| | | List<RoadExamMap3.RoadBean.SeparateBean.LaneLineBean> line = lines.get(z); |
| | | |
| | | for (int zz = 0; zz < line.size(); zz++) { |
| | | RoadExamMap3.RoadBean.SeparateBean.LaneLineBean seg = line.get(zz); |
| | | |
| | | Path sepPath = new Path(); |
| | | |
| | | if (seg.getType() == 0) { |
| | | Log.d(TAG, "虚线"); |
| | | paint.setPathEffect(new DashPathEffect(new float[] {40, 80}, 0)); |
| | | } else { |
| | | Log.d(TAG, "实线"); |
| | | paint.setPathEffect(new DashPathEffect(new float[] {10000, 0}, 0)); |
| | | } |
| | | |
| | | List<Integer> points = seg.getLine(); |
| | | |
| | | |
| | | int draw_status = 0; |
| | | |
| | | for (int za = 0; za < points.size()-1; za++) { |
| | | float scr_x = (float) (base_x + (map[points.get(za)][0] - min_x) * scale_x); |
| | | float scr_y = (float) (base_y + (map[points.get(za)][1] - min_y) * scale_y); |
| | | |
| | | float scr_x2 = (float) (base_x + (map[points.get(za+1)][0] - min_x) * scale_x); |
| | | float scr_y2 = (float) (base_y + (map[points.get(za+1)][1] - min_y) * scale_y); |
| | | |
| | | Line linex = new Line(scr_x, scr_y, scr_x2, scr_y2); |
| | | |
| | | Relation relation = IntersectionOf(linex, bmp.getWidth(), bmp.getHeight()); |
| | | if (relation == Relation.GM_Intersection || relation == Relation.GM_Containment) { |
| | | if (draw_status == 0) { |
| | | sepPath.moveTo(scr_x, scr_y); |
| | | sepPath.lineTo(scr_x2, scr_y2); |
| | | draw_status = 1; |
| | | } else if (draw_status == 1) { |
| | | sepPath.lineTo(scr_x2, scr_y2); |
| | | } |
| | | } else if (draw_status == 1) { |
| | | canvas2.drawPath(sepPath, paint); |
| | | draw_status = 0; |
| | | } |
| | | } |
| | | if (draw_status == 1) { |
| | | canvas2.drawPath(sepPath, paint); |
| | | draw_status = 0; |
| | | } |
| | | |
| | | // sepPath.moveTo((float) (base_x + (map[points.get(0)][0] - min_x) * scale_x), (float) (base_y + (map[points.get(0)][1] - min_y) * scale_y)); |
| | | // for (int za = 1; za < points.size(); za++) { |
| | | // sepPath.lineTo((float) (base_x + (map[points.get(za)][0] - min_x) * scale_x), (float) (base_y + (map[points.get(za)][1] - min_y) * scale_y)); |
| | | // } |
| | | // canvas2.drawPath(sepPath, paint); |
| | | } |
| | | } |
| | | |
| | | |
| | | /*if (line.getType() == 0) { |
| | | Log.d(TAG, "虚线"); |
| | | paint.setPathEffect(new DashPathEffect(new float[] {40, 80}, 0)); |
| | | } else { |
| | | Log.d(TAG, "实线"); |
| | | paint.setPathEffect(new DashPathEffect(new float[] {10000, 0}, 0)); |
| | | } |
| | | |
| | | List<List<Integer>> lines = sep.getLine(); |
| | | |
| | | Path sepPath = new Path(); |
| | | |
| | | for (int z = 0; z < lines.size(); z++) { |
| | | |
| | | List<Integer> line = lines.get(z); |
| | | |
| | | sepPath.moveTo((float) (base_x + (map[line.get(0)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(0)][1] - min_y) * scale_y)); |
| | | |
| | | for (int za = 1; za < line.size(); za++) { |
| | | sepPath.lineTo((float) (base_x + (map[line.get(za)][0] - min_x) * scale_x), (float) (base_y + (map[line.get(za)][1] - min_y) * scale_y)); |
| | | } |
| | | canvas2.drawPath(sepPath, paint); |
| | | |
| | | }*/ |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | if (specialAreaBeanList != null) { |
| | | Paint mPaint = new Paint(); |
| | | mPaint.setTextSize(20); |
| | | mPaint.setStyle(Paint.Style.FILL_AND_STROKE); |
| | | mPaint.setColor(Color.WHITE); |
| | | for (x = 0; x < specialAreaBeanList.size(); x++) { |
| | | RoadExamMap3.SpecialAreaBean specialArea = specialAreaBeanList.get(x); |
| | | |
| | | List<Integer> points = specialArea.getArea(); |
| | | |
| | | switch (specialArea.getType()) { |
| | | case 0: |
| | | paint.setColor(Color.GREEN); |
| | | break; |
| | | case 1: |
| | | paint.setColor(Color.RED); |
| | | break; |
| | | case 2: |
| | | paint.setColor(Color.BLUE); |
| | | break; |
| | | case 3: |
| | | paint.setColor(Color.YELLOW); |
| | | break; |
| | | } |
| | | |
| | | |
| | | |
| | | for (int y = 0; y < points.size(); y++) { |
| | | if (y == 0) { |
| | | Path pathText = new Path(); |
| | | pathText.moveTo((float) (base_x + (map[points.get(y)][0] - min_x) * scale_x), (float) (base_y + (map[points.get(y)][1] - min_x) * scale_y)); |
| | | pathText.lineTo((float) (base_x + (map[points.get(y)][0] - min_x) * scale_x) + 60.0f, (float) (base_y + (map[points.get(y)][1] - min_x) * scale_y)); |
| | | canvas2.drawTextOnPath(String.format("%d: %d - %d", specialArea.getRoad(), specialArea.getId(), specialArea.getType()), pathText, 0, 0, mPaint);//逆时针生成 |
| | | } |
| | | |
| | | canvas2.drawCircle((float) (base_x + (map[points.get(y)][0] - min_x) * scale_x), (float) (base_y + (map[points.get(y)][1] - min_x) * scale_y), 2.5f, paint); |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | paint.setColor(Color.WHITE); |
| | | |
| | | PointF tp = ConvertScreen(428909.046, 3291970.692, yaw, mainPoint); |
| | | canvas2.drawCircle((float) (base_x + (tp.getX() - min_x) * scale_x), (float) (base_y + (tp.getY() - min_y) * scale_y), 5.0f, paint); |
| | | tp = ConvertScreen(428864.169, 3292181.902, yaw, mainPoint); |
| | | canvas2.drawCircle((float) (base_x + (tp.getX() - min_x) * scale_x), (float) (base_y + (tp.getY() - min_y) * scale_y), 5.0f, paint); |
| | | tp = ConvertScreen(428507.796, 3292262.818, yaw, mainPoint); |
| | | canvas2.drawCircle((float) (base_x + (tp.getX() - min_x) * scale_x), (float) (base_y + (tp.getY() - min_y) * scale_y), 5.0f, paint); |
| | | tp = ConvertScreen(428041.147, 3292240.051, yaw, mainPoint); |
| | | canvas2.drawCircle((float) (base_x + (tp.getX() - min_x) * scale_x), (float) (base_y + (tp.getY() - min_y) * scale_y), 5.0f, paint); |
| | | tp = ConvertScreen(427961.753, 3292170.694, yaw, mainPoint); |
| | | canvas2.drawCircle((float) (base_x + (tp.getX() - min_x) * scale_x), (float) (base_y + (tp.getY() - min_y) * scale_y), 5.0f, paint); |
| | | |
| | | } |
| | | |
| | | |
| | | // 提交画布 |
| | | Canvas canvas = holder.lockCanvas(); |
| | | if (canvas != null){ |
| | | |
| | | canvas.drawBitmap(bmp, 0, 0, paint); |
| | | // canvas.drawBitmap(bmp2, screen_width*2/3, 0, paint); |
| | | holder.unlockCanvasAndPost(canvas); |
| | | Log.d(TAG, "提交画布"); |
| | | } |
| | | } |
| | | /** |
| | | * 通过资源id转化成Bitmap |
| | | * |
| | | * @param resId |
| | | * @return |
| | | */ |
| | | public Bitmap readBitmapById(int resId){ |
| | | // BitmapFactory.Options opt = new BitmapFactory.Options(); |
| | | // opt.inPreferredConfig = Bitmap.Config.ARGB_8888; |
| | | InputStream is = getResources().openRawResource(resId); |
| | | return BitmapFactory.decodeStream(is); |
| | | } |
| | | |
| | | |
| | | public PointF ConvertScreen(double x, double y, double yaw, PointF mainPoint) { |
| | | PointF oldPoint = new PointF(x, y); |
| | | PointF newPoint = rotatePoint(oldPoint, mainPoint, yaw ); |
| | | x = newPoint.getX(); |
| | | y = newPoint.getY(); |
| | | |
| | | x = x - mainPoint.getX(); |
| | | y = y - mainPoint.getY(); |
| | | y = -y; |
| | | |
| | | newPoint = new PointF(x, y); |
| | | return newPoint; |
| | | } |
| | | |
| | | /** |
| | | * 缩放图片 |
| | | * @param bm 要缩放图片 |
| | | * @param newWidth 宽度 |
| | | * @param newHeight 高度 |
| | | * @return处理后的图片 |
| | | */ |
| | | public Bitmap scaleImage(Bitmap bm, int newWidth, int newHeight){ |
| | | if (bm == null){ |
| | | return null; |
| | | } |
| | | int width = bm.getWidth(); |
| | | int height = bm.getHeight(); |
| | | float scaleWidth = ((float) newWidth) / width; |
| | | float scaleHeight = ((float) newHeight) / height; |
| | | Matrix matrix = new Matrix(); |
| | | matrix.postScale(scaleWidth, scaleHeight); |
| | | Bitmap newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix,true); |
| | | if (bm != null & !bm.isRecycled()){ |
| | | bm.recycle();//销毁原图片 |
| | | bm = null; |
| | | } |
| | | return newbm; |
| | | } |
| | | |
| | | /** |
| | | * 旋转图片 |
| | | * @param angle 旋转角度 |
| | | * @param bitmap 要处理的Bitmap |
| | | * @return 处理后的Bitmap |
| | | */ |
| | | public Bitmap rotaingImageView(int angle, Bitmap bitmap) |
| | | { |
| | | // 旋转图片 动作 |
| | | Matrix matrix = new Matrix(); |
| | | matrix.postRotate(angle); |
| | | // 创建新的图片 |
| | | Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, |
| | | bitmap.getWidth(), bitmap.getHeight(), matrix, true); |
| | | if (resizedBitmap != bitmap && bitmap != null && !bitmap.isRecycled()){ |
| | | bitmap.recycle(); |
| | | bitmap = null; |
| | | } |
| | | return resizedBitmap; |
| | | } |
| | | |
| | | |
| | | int line = 0; |
| | | int map_line = 0; |
| | | class MessageRemoteService{ |
| | | public int msgCode; |
| | | public String json; |
| | | |
| | | public MessageRemoteService(int msgCode, Object obj) { |
| | | this.json = (String) obj; |
| | | this.msgCode = msgCode; |
| | | } |
| | | } |
| | | |
| | | RoadExamMap examMaps ; |
| | | private ICEventListener icEventListener = new ICEventListener() { |
| | | @Override |
| | | public void onCEvent(String topic, final int msgCode, int resultCode, final Object obj) { |
| | | |
| | | |
| | | producer.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | queue.offer(new MessageRemoteService(msgCode,obj)); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | }; |
| | | boolean flag = true; |
| | | String newmap = null; |
| | | class CalRunnable implements Runnable{ |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void run() { |
| | | while (flag) { |
| | | MessageRemoteService messageRemoteService = (MessageRemoteService) queue.peek(); |
| | | if (messageRemoteService == null) { |
| | | Log.i(TAG, "messageRemoteService ==null"); |
| | | |
| | | try { |
| | | Thread.sleep(100); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | messageRemoteService = (MessageRemoteService) queue.poll(); |
| | | if (messageRemoteService != null) { |
| | | MyLog.i(TAG, messageRemoteService.json+" 消息队列长度:"+queue.size()); |
| | | |
| | | |
| | | RealTimeCarPos timeCarPos = gson.fromJson((String) messageRemoteService.json, RealTimeCarPos.class); |
| | | |
| | | List<Double> points = timeCarPos.getPoint(); |
| | | switch (timeCarPos.getMove()) { |
| | | case 0: |
| | | osdMoveDirect = "停车"; |
| | | break; |
| | | case 1: |
| | | osdMoveDirect = "前进"; |
| | | break; |
| | | case -1: |
| | | osdMoveDirect = "后退"; |
| | | break; |
| | | } |
| | | osdHeading = "方向角" + String.valueOf(timeCarPos.getHeading()); |
| | | |
| | | BigDecimal bd = new BigDecimal(timeCarPos.getSpeed()); |
| | | bd = bd.setScale(3, BigDecimal.ROUND_HALF_UP); |
| | | osdRtkSpeed = "计算速度:" + bd; |
| | | |
| | | osdQf = "QF:" + String.valueOf(timeCarPos.getQf()); |
| | | |
| | | |
| | | car = new double[points.size() / 2][2]; |
| | | line =0 ;map_line=0; |
| | | for (int i = 0; i < points.size(); i++) { |
| | | if ((i % 2) == 0) { |
| | | car[line][0] = points.get(i); |
| | | } else { |
| | | double value = points.get(i); |
| | | car[line][1] = value; |
| | | line++; |
| | | } |
| | | |
| | | } |
| | | map_id = timeCarPos.getMap_id(); |
| | | |
| | | List<Double> mainAnt = timeCarPos.getMain_ant(); |
| | | List<Integer> tire1 = timeCarPos.getLeft_front_tire(); |
| | | List<Integer> tire2 = timeCarPos.getRight_front_tire(); |
| | | List<Integer> tire3 = timeCarPos.getLeft_rear_tire(); |
| | | List<Integer> tire4 = timeCarPos.getRight_rear_tire(); |
| | | |
| | | List<Integer> body = timeCarPos.getBody(); |
| | | |
| | | List<Integer> tire = new ArrayList<>(); |
| | | |
| | | double yaw = timeCarPos.getHeading(); |
| | | |
| | | tire.add(tire1.get(0)); |
| | | tire.add(tire2.get(0)); |
| | | tire.add(tire3.get(0)); |
| | | tire.add(tire4.get(0)); |
| | | |
| | | |
| | | |
| | | final String roadMapPath = ExamPlatformData.getInstance().getRoadMapPath(); |
| | | |
| | | if (!TextUtils.isEmpty(roadMapPath)){ |
| | | Log.d(TAG, "地图路径 " + roadMapPath); |
| | | byte [] datas= FileUtil.readFile(roadMapPath); |
| | | if (datas != null){ |
| | | newmap= new String(datas); |
| | | }else{ |
| | | MyLog.i(String.format("文件:%s不存在",roadMapPath)); |
| | | } |
| | | |
| | | }else{ |
| | | |
| | | buffer = FileUtil.readAssetTxtFile(_mActivity, Constant.ROAD_MAP); |
| | | Log.i(TAG, "ditu=" + buffer.toString().trim()); |
| | | } |
| | | |
| | | |
| | | /*Type type = new TypeToken<RoadExamMap>() { |
| | | }.getType(); |
| | | if (buffer != null) { |
| | | examMaps = gson.fromJson(buffer.toString().trim(), type); |
| | | }else{ |
| | | examMaps = gson.fromJson(newmap.trim(),type); |
| | | } |
| | | if (examMaps != null) { |
| | | |
| | | points = examMaps.getPoints(); |
| | | if (points != null) { |
| | | map = new double[points.size() / 2][2]; |
| | | for (int i = 0; i < points.size(); i++) { |
| | | if ((i % 2) == 0) { |
| | | map[map_line][0] = points.get(i); |
| | | |
| | | } else { |
| | | double value = points.get(i); |
| | | map[map_line][1] = value; |
| | | map_line++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | DrawMap(yaw, mainAnt,map, car, body, tire, examMaps.getMaps());*/ |
| | | |
| | | |
| | | RoadExamMap3 roadExamMap3 = null; |
| | | Type type2 = new TypeToken<RoadExamMap3>() { |
| | | }.getType(); |
| | | |
| | | if (buffer != null) { |
| | | Log.d(TAG, "解析地图1 " + buffer.toString().trim()); |
| | | roadExamMap3 = gson.fromJson(buffer.toString().trim(), type2); |
| | | }else{ |
| | | Log.d(TAG, "解析地图2 " + newmap.trim()); |
| | | roadExamMap3 = gson.fromJson(newmap.trim(),type2); |
| | | } |
| | | if (roadExamMap3 != null) { |
| | | points = roadExamMap3.getPoints(); |
| | | Log.d(TAG, "地图数量 %d" + points.size()); |
| | | if (points != null) { |
| | | map = new double[points.size() / 2][2]; |
| | | for (int i = 0; i < points.size(); i++) { |
| | | if ((i % 2) == 0) { |
| | | map[map_line][0] = points.get(i); |
| | | |
| | | } else { |
| | | double value = points.get(i); |
| | | map[map_line][1] = value; |
| | | map_line++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | DrawMap2(yaw, mainAnt, map, car, body, tire, roadExamMap3.getRoad(), roadExamMap3.getSpecial_area()); |
| | | // DrawMap(yaw, mainAnt, map, car, body, tire, null); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | @Override |
| | | public void onAttach(Context context) { |
| | | super.onAttach(context); |
| | | CEventCenter.onBindEvent(true, icEventListener, Constant.REAL_TIME_POS_CAR_TOPIC); |
| | | CEventCenter.onBindEvent(true, speedListener, Constant.BIND_RTK_SPEED_TOPIC); |
| | | } |
| | | |
| | | @Override |
| | | public void onDetach() { |
| | | super.onDetach(); |
| | | flag = false; |
| | | producer.shutdown(); |
| | | consumer.shutdown(); |
| | | CEventCenter.onBindEvent(false, icEventListener, Constant.REAL_TIME_POS_CAR_TOPIC); |
| | | CEventCenter.onBindEvent(false, speedListener, Constant.BIND_RTK_SPEED_TOPIC); |
| | | } |
| | | @Override |
| | | public void onClick(View v) { |
| | | switch (v.getId()){ |
| | | case R.id.btn_reduce: |
| | | |
| | | if (pixels < 5){ |
| | | pixels = 5; |
| | | Toast.makeText(_mActivity, "已经是最小了,不能再小了", Toast.LENGTH_SHORT).show(); |
| | | }else{ |
| | | pixels -= 5; |
| | | } |
| | | break; |
| | | case R.id.btn_amplify: |
| | | if (pixels >80){ |
| | | Toast.makeText(_mActivity, "已经是最大了", Toast.LENGTH_SHORT).show(); |
| | | pixels = 80; |
| | | }else{ |
| | | pixels+=5; |
| | | } |
| | | break; |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | void DrawArrows(Canvas canvas, int color, float arrowSize, float x1, |
| | | float y1, float x2, float y2) { |
| | | paint.setAntiAlias(true); |
| | | paint.setStyle(Paint.Style.STROKE); |
| | | paint.setColor(color); |
| | | |
| | | // 画直线 |
| | | canvas.drawLine(x1, y1, x2, y2, paint); |
| | | |
| | | // 箭头中的第一条线的起点 |
| | | int x3 = 0; |
| | | int y3 = 0; |
| | | |
| | | // 箭头中的第二条线的起点 |
| | | int x4 = 0; |
| | | int y4 = 0; |
| | | |
| | | double awrad = Math.atan(3.5 / 8); |
| | | double[] arrXY_1 = rotateVec(x2 - x1, y2 - y1, awrad, arrowSize); |
| | | double[] arrXY_2 = rotateVec(x2 - x1, y2 - y1, -awrad, arrowSize); |
| | | |
| | | // 第一端点 |
| | | Double X3 = Double.valueOf(x2 - arrXY_1[0]); |
| | | x3 = X3.intValue(); |
| | | Double Y3 = Double.valueOf(y2 - arrXY_1[1]); |
| | | y3 = Y3.intValue(); |
| | | |
| | | // 第二端点 |
| | | Double X4 = Double.valueOf(x2 - arrXY_2[0]); |
| | | x4 = X4.intValue(); |
| | | Double Y4 = Double.valueOf(y2 - arrXY_2[1]); |
| | | y4 = Y4.intValue(); |
| | | |
| | | Path arrowsPath = new Path(); |
| | | arrowsPath.moveTo(x2, y2); |
| | | arrowsPath.lineTo(x3, y3); |
| | | arrowsPath.lineTo(x4, y4); |
| | | arrowsPath.close(); |
| | | canvas.drawLine(x3, y3, x2, y2, paint); |
| | | canvas.drawLine(x4, y4, x2, y2, paint); |
| | | } |
| | | |
| | | private double[] rotateVec(float px, float py, double ang, double arrowSize) { |
| | | double mathstr[] = new double[2]; |
| | | double vx = px * Math.cos(ang) - py * Math.sin(ang); |
| | | double vy = px * Math.sin(ang) + py * Math.cos(ang); |
| | | double d = Math.sqrt(vx * vx + vy * vy); |
| | | vx = vx / d * arrowSize; |
| | | vy = vy / d * arrowSize; |
| | | mathstr[0] = vx; |
| | | mathstr[1] = vy; |
| | | return mathstr; |
| | | } |
| | | |
| | | |
| | | } |