import processing.core.PApplet;

//xmax = 2384
//xmin = -1250
//ymax = 1962
//ymin = -1092

public class RoadVertex {
	private static final int SEGX = 50;
	private static final int SEGY = 50;
	private static final int xmax = 2384;
	private static final int xmin = -1250;
	private static final int ymax = 1962;
	private static final int ymin = -1092;
	private static final int width = xmax - xmin;
	private static final int height = ymax - ymin;
	private static final float xSegWidth = width/SEGX;
	private static final float ySegWidth = height/SEGY;
	
	private PApplet p;
	private float x, y;
	private String id;
	private int segment;


	public int getSegment() {
		return segment;
	}

	public void setSegment(int segment) {
		this.segment = segment;
	}

	public RoadVertex(PApplet parent, float x, float y, String id) {
		p = parent;
		this.x = x;
		this.y = y;
		this.id = id;
		segment = xyToSegment();
	}

	private int xyToSegment() {
		int xsegment = (int) ((x + 1250) / xSegWidth) + 1;
		int ysegment = (int) ((y + 1092) / ySegWidth) + 1;
		segment = (ysegment * SEGX + xsegment) ; 
		return segment;
	}

	public void draw() {
		p.ellipse(x, y, 3, 3);
	}

	public float getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

}

