use of org.openstreetmap.osmosis.core.domain.v0_6.Bound in project osmosis by openstreetmap.
the class OsmHandlerTest method testBoundsOriginInheritance.
/**
* Test the inheritance of generator to the origin.
*/
@Test
public void testBoundsOriginInheritance() {
parseString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<osm version=\"0.6\" generator=\"somegenerator\">" + "<bounds minlat=\"-1.234\" minlon=\"-1.234\" maxlat=\"1.234\" maxlon=\"1.234\"/>" + "</osm>");
Bound b = (Bound) entityInspector.getLastEntityContainer().getEntity();
assertEquals("somegenerator", b.getOrigin());
}
use of org.openstreetmap.osmosis.core.domain.v0_6.Bound in project osmosis by openstreetmap.
the class OsmHandlerTest method testBoundElement1.
/**
* Test a normal, well-formed bound element.
*/
@Test
public final void testBoundElement1() {
parseString(OSM_PREFIX + "<bound box=\"-12.34567,-23.45678,34.56789,45.67891\"" + " origin=\"someorigin\"/>" + OSM_SUFFIX);
Bound b = (Bound) entityInspector.getLastEntityContainer().getEntity();
assertTrue(Double.compare(b.getRight(), 45.67891) == 0 && Double.compare(b.getLeft(), -23.45678) == 0 && Double.compare(b.getTop(), 34.56789) == 0 && Double.compare(b.getBottom(), -12.34567) == 0);
assertTrue(b.getOrigin().equals("someorigin"));
}
use of org.openstreetmap.osmosis.core.domain.v0_6.Bound in project osmosis by openstreetmap.
the class OsmWriterTest method testProcess4.
/**
* Test processing a Bound after a Node.
*/
@Test(expected = OsmosisRuntimeException.class)
public final void testProcess4() {
testOsmWriter.process(new NodeContainer(new Node(new CommonEntityData(1234, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0, new ArrayList<Tag>()), 20, 20)));
testOsmWriter.process(new BoundContainer(new Bound("source")));
fail("Expected to throw an exception.");
}
use of org.openstreetmap.osmosis.core.domain.v0_6.Bound in project osmosis by openstreetmap.
the class OsmWriterTest method testProcess9.
/**
* Test processing a Bound after a Relation.
*/
@Test(expected = OsmosisRuntimeException.class)
public final void testProcess9() {
Relation testRelation;
testRelation = new Relation(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
testRelation.getMembers().add(new RelationMember(1234, EntityType.Node, "role1"));
testRelation.getTags().add(new Tag("test_key1", "test_value1"));
testOsmWriter.process(new RelationContainer(testRelation));
testOsmWriter.process(new BoundContainer(new Bound("source")));
}
use of org.openstreetmap.osmosis.core.domain.v0_6.Bound in project osmosis by openstreetmap.
the class XmlDownloader method run.
/**
* Reads all data from the server and send it to the {@link Sink}.
*/
public void run() {
try {
mySink.initialize(Collections.<String, Object>emptyMap());
SAXParser parser = createParser();
InputStream inputStream = getInputStream(myBaseUrl + "/map?bbox=" + myLeft + "," + myBottom + "," + myRight + "," + myTop);
// First send the Bound down the pipeline
mySink.process(new BoundContainer(new Bound(myRight, myLeft, myTop, myBottom, myBaseUrl)));
try {
parser.parse(inputStream, new OsmHandler(mySink, true));
} finally {
inputStream.close();
inputStream = null;
}
mySink.complete();
} catch (SAXParseException e) {
throw new OsmosisRuntimeException("Unable to parse xml" + ". publicId=(" + e.getPublicId() + "), systemId=(" + e.getSystemId() + "), lineNumber=" + e.getLineNumber() + ", columnNumber=" + e.getColumnNumber() + ".", e);
} catch (SAXException e) {
throw new OsmosisRuntimeException("Unable to parse XML.", e);
} catch (IOException e) {
throw new OsmosisRuntimeException("Unable to read XML.", e);
} finally {
mySink.close();
cleanup();
}
}
Aggregations