Formatting

This commit is contained in:
Roman Inflianskas 2016-06-09 00:00:51 +03:00
parent 979971fc69
commit b468c8e2e4

View file

@ -11,7 +11,7 @@ import net.osmand.data.LatLon;
import net.osmand.data.QuadRect;
public class Way extends Entity {
// lazy loading
private TLongArrayList nodeIds = null;
private List<Node> nodes = null;
@ -19,7 +19,7 @@ public class Way extends Entity {
public Way(long id) {
super(id);
}
public Way(Way w) {
super(w.getId());
if (w.nodeIds != null) {
@ -29,7 +29,7 @@ public class Way extends Entity {
nodes = new ArrayList<Node>(w.nodes);
}
}
public Way(long id, List<Node> nodes) {
super(id);
this.nodes = new ArrayList<Node>(nodes);
@ -38,84 +38,84 @@ public class Way extends Entity {
nodeIds.add(n.getId());
}
}
public void addNode(long id){
if(nodeIds == null){
public void addNode(long id) {
if (nodeIds == null) {
nodeIds = new TLongArrayList();
}
nodeIds.add(id);
}
public long getFirstNodeId(){
if(nodeIds == null){
public long getFirstNodeId() {
if (nodeIds == null) {
return -1;
}
return nodeIds.get(0);
}
public long getLastNodeId(){
if(nodeIds == null){
public long getLastNodeId() {
if (nodeIds == null) {
return -1;
}
return nodeIds.get(nodeIds.size() - 1);
}
public Node getFirstNode(){
if(nodes == null || nodes.size() == 0){
public Node getFirstNode() {
if (nodes == null || nodes.size() == 0) {
return null;
}
return nodes.get(0);
}
public Node getLastNode(){
if(nodes == null || nodes.size() == 0){
public Node getLastNode() {
if (nodes == null || nodes.size() == 0) {
return null;
}
return nodes.get(nodes.size() - 1);
}
public void addNode(Node n){
if(nodeIds == null){
public void addNode(Node n) {
if (nodeIds == null) {
nodeIds = new TLongArrayList();
}
if(nodes == null){
if (nodes == null) {
nodes = new ArrayList<Node>();
}
nodeIds.add(n.getId());
nodes.add(n);
}
public void addNode(Node n, int index){
if(nodeIds == null){
public void addNode(Node n, int index) {
if (nodeIds == null) {
nodeIds = new TLongArrayList();
}
if(nodes == null){
if (nodes == null) {
nodes = new ArrayList<Node>();
}
nodeIds.insert(index, n.getId());
nodes.add(index, n);
}
public long removeNodeByIndex(int i){
if(nodeIds == null){
public long removeNodeByIndex(int i) {
if (nodeIds == null) {
return -1;
}
long toReturn = nodeIds.removeAt(i);
if(nodes != null && nodes.size() > i){
if (nodes != null && nodes.size() > i) {
nodes.remove(i);
}
return toReturn;
}
public TLongArrayList getNodeIds(){
if(nodeIds == null){
public TLongArrayList getNodeIds() {
if (nodeIds == null) {
return new TLongArrayList(0);
}
return nodeIds;
}
public List<EntityId> getEntityIds(){
if(nodeIds == null){
public List<EntityId> getEntityIds() {
if (nodeIds == null) {
return Collections.emptyList();
}
List<EntityId> ls = new ArrayList<EntityId>();
@ -124,70 +124,71 @@ public class Way extends Entity {
}
return ls;
}
public List<Node> getNodes() {
if(nodes == null){
if (nodes == null) {
return Collections.emptyList();
}
return nodes;
}
@Override
public void initializeLinks(Map<EntityId, Entity> entities) {
if (nodeIds != null) {
if(nodes == null){
nodes = new ArrayList<Node>();
if (nodes == null) {
nodes = new ArrayList<Node>();
} else {
nodes.clear();
}
int nIsize = nodeIds.size();
for (int i = 0; i < nIsize; i++) {
nodes.add((Node) entities.get(new EntityId(EntityType.NODE,nodeIds.get(i))));
nodes.add((Node) entities.get(new EntityId(EntityType.NODE, nodeIds.get(i))));
}
}
}
public QuadRect getLatLonBBox() {
QuadRect qr = null;
if(nodes != null) {
for(Node n : nodes){
if(qr == null) {
if (nodes != null) {
for (Node n : nodes) {
if (qr == null) {
qr = new QuadRect();
qr.left = (float) n.getLongitude();
qr.right = (float) n.getLongitude();
qr.top = (float) n.getLatitude();
qr.top = (float) n.getLatitude();
qr.bottom = (float) n.getLatitude();
}
if(n.getLongitude() < qr.left) {
if (n.getLongitude() < qr.left) {
qr.left = (float) n.getLongitude();
} else if(n.getLongitude() > qr.right) {
} else if (n.getLongitude() > qr.right) {
qr.right = (float) n.getLongitude();
}
if(n.getLatitude() > qr.top) {
if (n.getLatitude() > qr.top) {
qr.top = (float) n.getLatitude();
} else if(n.getLatitude() < qr.bottom) {
} else if (n.getLatitude() < qr.bottom) {
qr.bottom = (float) n.getLatitude();
}
}
}
return qr;
}
@Override
public LatLon getLatLon() {
if(nodes == null){
if (nodes == null) {
return null;
}
return OsmMapUtils.getWeightCenterForWay(this);
}
public void reverseNodes() {
if(nodes != null) {
Collections.reverse(nodes);
}
if(nodeIds != null) {
nodeIds.reverse();;
}
}
public void reverseNodes() {
if (nodes != null) {
Collections.reverse(nodes);
}
if (nodeIds != null) {
nodeIds.reverse();
;
}
}
}