Can someone help me with this assignment with crossingnumber in java ? Write a p
ID: 3773624 • Letter: C
Question
Can someone help me with this assignment with crossingnumber in java ?
Write a program that reads two command-line arguments x and y, and
then (through redirection) KaartBE.txt the file via the standard input
reads. Your program then determines
1. In which province and which region the point (x, y). Use
The crossing number algorithm described in the appendix. If it
point does not appear to be in Belgium, this is reported.
2. The distance to which the closest provincial, and which province here
is adjacent to.
Use for this is that in Belgium one degree longitude (x = 1) is approximately equivalent
is up to 71.43km and a degree of latitude (y = 1) is approximately equal to111.27km.
KaartBe.txt the file looks like this
0 Bruxelles
1 Flanders Antwerp
2 Flanders Antwerp
3 Flanders Limburg
4 Flanders Limburg
5 Flanders East Flanders
6 Flanders Flemish Brabant
7 Flanders Flemish Brabant
8 West Flanders
9 West Flanders
10 Wallonie Brabant Wallon
11 Wallonie Hainaut
12 Wallonie Hainaut
13 Wallonie Liege
14 Wallonie Limburg
15 Wallonie Luxembourg
16 Wallonie Namur
0 4.409863 50.909904
0 4.412506 50.909237
0 4.421847 50.909714
0 4.426921 50.903301
0 4.428299 50.900524
0 4.428676 50.898235
.
.
.
16 4.989914 50.627438
16 4.987081 50.620743
16 4.985815 50.615128
The first 17 lines are one index. Each line of the index is a
polygon, and includes an integer between 0 and ID 16, a region name
(a word) and a province (the rest of the line.) For example, the line
6 Flanders Flemish Brabant
indicates that the 6th polygon is part of the province of Flemish Brabant
in Flanders.
Each ID does exactly one time in the index, but a province
may occur in different id numbers because the border from
several pieces exist (see for example the `hole 'in Bruxelles
the province of Flemish Brabant.)
The following 10 632 lines contain a coordinate table. Each line of
This table contains an integer ID between 0 and 17 which refers to the
index, an x coordinate (the longitude) and y coordinate (latitude).
All rules in the coordination table that begin with the same id give the coordinates of the vertices of a polygon on. Forming this polygonthe boundary of a (part of) a province.
For example, the successive line
0 4.421847 50.909714
0 4.426921 50.903301
indicate that the line section with end points (4.421847; 50.909714)
and (4.426921; 50:903301) forms a part of the boundary of Bruxelles.
The crossing number counts the number of times the line of (p, q) to (+ , q) intersects the province. The province line is considered here as the line segments between n consecutive points (x1, y1) to (xn.yn) and the line segment from (xn, yn) back to (x0, y0).
For example in the following picture is a fictional provincial consisting of six segments. The dashed horizontal line intersects the boundary three times, so the crossing number is equal to 3.
If the crossing number is odd, then (p,q) is in the province. If the crossingnumber is even the then is it outside the province.
the line (p,q)to (Xb, YXB) instersect with (xa,ya) to (xb,yb) if both condtions are met:
- ya>q and yb<q or ya<q and yb>q
- p-xa <(xb-xa) (q-ya) / (YB-ya)
Example Run
% Java KaartBE 4.35 50.84 <KaartBE.txt
The point: x = 4.35 y = 50.84 set in
Province: Bruxelles,
Region: Bruxelles.
Which the closest other province of Flemish Brabant in Flanders
at a distance of 4.652km.