int r2x = h2.getXa(); int r2y = h2.getYa(); int R = 0; if (r1x == r2x) { if (r1y == r2y) { R = 0; } else { if (r1y > r2y) { R = 1; } else { R = -1; } } } else { if (r1x > r2x) { R = 1; } else { R = -1; } } return R; } } class Hotel implements WritableComparable<Hotel>, Cloneable { private IntWritable Type; private IntWritable ID; private IntWritable X; private IntWritable Y; private IntWritable Xa; private IntWritable Ya; private DoubleWritable Distance; { Type = new IntWritable(); ID = new IntWritable(); X = new IntWritable(); Y = new IntWritable(); Xa = new IntWritable(); Ya = new IntWritable(); Distance = new DoubleWritable(); } public int getType() { return Type.get(); } public int getID() { return ID.get(); } public int getX() { return X.get(); } public int getY() { return Y.get(); } public int getXa() { return Xa.get(); } public int getYa() { return Ya.get(); } public void setXYa(int xd, int yd) { this.Xa.set(X.get() / 1000 + xd); this.Ya.set(Y.get() / 1000 + yd); } public double getDistance() { return Distance.get(); } public void setHotel(Text Str) { String[] v = Str.toString().split("\t"); Type.set(Integer.parseInt(v[0])); ID.set(Integer.parseInt(v[1])); X.set(Integer.parseInt(v[2])); Y.set(Integer.parseInt(v[3])); Xa.set(Integer.parseInt(v[2]) / 1000); Ya.set(Integer.parseInt(v[3]) / 1000); Distance.set(Math.sqrt(Math.pow(getX(), 2) + Math.pow(getX(), 2))); } @Override 上一页 [1] [2] [3] [4] [5] [6] 下一页
|