Index: applications/editors/josm/plugins/pdfimport/src/pdfimport/FilePlacement.java
===================================================================
--- applications/editors/josm/plugins/pdfimport/src/pdfimport/FilePlacement.java	(revision 24179)
+++ applications/editors/josm/plugins/pdfimport/src/pdfimport/FilePlacement.java	(revision 24186)
@@ -1,4 +1,8 @@
 package pdfimport;
 
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
 import java.util.Properties;
 
@@ -18,4 +22,7 @@
 	public double minNorth = 0;
 	public double maxNorth = 10000;
+	
+	private AffineTransform transform;
+
 
 	public void setPdfBounds(double minX, double minY, double maxX, double maxY){
@@ -31,5 +38,5 @@
 		this.minNorth = minNorth;
 		this.maxNorth = maxNorth;
-	}
+	}	
 
 	public Properties toProperties() {
@@ -91,18 +98,72 @@
 	}
 
+	
+	public String prepareTransform()
+	{
+		if (this.minX >= this.maxX){
+			return tr("Transform error: Min X must be smaller than max");
+		}
+
+		if (this.minY >= this.maxY){
+			return tr("Transform error: Min Y must be smaller than max");
+		}
+		
+		
+		if (this.minEast < this.maxEast && this.minNorth < this.maxNorth) {
+			//no rotation
+			this.transform = new AffineTransform();
+			this.transform.translate(-this.minX, -this.minY);
+			this.transform.scale(
+					(this.maxEast - this.minEast) / (this.maxX - this.minX),
+					(this.maxNorth - this.minNorth) /  (this.maxY - this.minY));
+			this.transform.translate(this.minEast, this.minNorth);
+		} else if (this.minEast < this.maxEast && this.minNorth > this.maxNorth) {
+			//need to rotate 90 degrees counterclockwise
+			//transform to 0..1, 0..1 range
+			this.transform.translate(-this.minX, -this.minY);
+			this.transform.scale(1/(this.maxX - this.minX), 1/(this.minY - this.maxY));
+			
+			//rotate -90 degs around center
+			this.transform.quadrantRotate(-1,  0.5, 0.5);
+			
+			//transform back to target range
+			this.transform.scale(
+					(this.maxEast - this.minEast),
+					(this.minNorth - this.maxNorth));
+			this.transform.translate(this.minEast, this.maxNorth);			
+		} else if (this.minEast > this.maxEast && this.minNorth < this.maxNorth) {
+			//need to rotate 90 degrees clockwise
+			//transform to 0..1, 0..1 range
+			this.transform.translate(-this.minX, -this.minY);
+			this.transform.scale(1/(this.maxX - this.minX), 1/(this.maxY - this.minY));
+			
+			//rotate 90 degs around center
+			this.transform.quadrantRotate(1, 0.5, 0.5);
+			
+			//transform back to target range
+			this.transform.scale(
+					(this.minEast - this.maxEast),
+					(this.maxNorth - this.minNorth));
+			this.transform.translate(this.maxEast, this.minNorth);			
+		}		
+		else
+		{
+			return tr("Transform error: Unsupported orientation");
+		}
+		
+		return null;
+			
+	}	
+	
 	EastNorth en = new EastNorth(0, 0);
+	Point2D src = new Point2D.Double();
 
-	public LatLon tranformCoords(double x, double y) {
+	public LatLon tranformCoords(Point2D pt) {
 
 		if (this.projection == null){
-			//en.setLocation(x * 1024,y * 1024);
-			//return Main.proj.eastNorth2latlon( en);
-			return new LatLon(y / 1000, x / 1000);
+			return new LatLon(pt.getY() / 1000, pt.getX() / 1000);
 		}
 		else{
-
-			x = (x - this.minX) * (this.maxEast - this.minEast) / (this.maxX - this.minX)  + this.minEast;
-			y = (y - this.minY) * (this.maxNorth - this.minNorth) /  (this.maxY - this.minY) + this.minNorth;
-			en.setLocation(x,y);
+			this.transform.transform(pt, en);
 			return this.projection.eastNorth2latlon(en);
 		}
@@ -111,7 +172,5 @@
 	public EastNorth reverseTransform(LatLon coor) {
 		if (this.projection == null){
-			//EastNorth result = this.projection.latlon2eastNorth(coor);
-			//result.setLocation(result.east() / 1024, result.north() / 1024);
-			//return result;
+
 			return new EastNorth(coor.lon() * 1000, coor.lat() * 1000);
 		}
Index: applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java
===================================================================
--- applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java	(revision 24179)
+++ applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java	(revision 24186)
@@ -176,5 +176,5 @@
 		this.debugModeCheck = new JCheckBox(tr("Debug info"));
 		this.mergeCloseNodesCheck = new JCheckBox(tr("Merge close nodes"));
-		this.mergeCloseNodesTolerance = new JTextField("1e-6");
+		this.mergeCloseNodesTolerance = new JTextField("1e-3");
 
 		this.removeSmallObjectsCheck = new JCheckBox(tr("Remove objects smaller than"));
@@ -196,28 +196,28 @@
 		c.gridx = 0; c.gridy = 0; c.gridwidth = 1;
 		configPanel.add(this.mergeCloseNodesCheck, c);
-		c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.anchor = c.NORTHEAST;
+		c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHEAST;
 		configPanel.add(new JLabel("Tolerance :"), c);
-		c.gridx = 2; c.gridy = 0; c.gridwidth = 1; c.anchor = c.NORTHWEST;
+		c.gridx = 2; c.gridy = 0; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST;
 		configPanel.add(this.mergeCloseNodesTolerance, c);
 
 		c.gridx = 0; c.gridy = 1; c.gridwidth = 1;
 		configPanel.add(this.removeSmallObjectsCheck, c);
-		c.gridx = 1; c.gridy = 1; c.gridwidth = 1; c.anchor = c.NORTHEAST;
+		c.gridx = 1; c.gridy = 1; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHEAST;
 		configPanel.add(new JLabel("Tolerance :"), c);
-		c.gridx = 2; c.gridy = 1; c.gridwidth = 1; c.anchor = c.NORTHWEST;
+		c.gridx = 2; c.gridy = 1; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST;
 		configPanel.add(this.removeSmallObjectsSize, c);
 
 		c.gridx = 0; c.gridy = 2; c.gridwidth = 1;
 		configPanel.add(this.removeLargeObjectsCheck, c);
-		c.gridx = 1; c.gridy = 2; c.gridwidth = 1; c.anchor = c.NORTHEAST;
+		c.gridx = 1; c.gridy = 2; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHEAST;
 		configPanel.add(new JLabel("Tolerance :"), c);
-		c.gridx = 2; c.gridy = 2; c.gridwidth = 1; c.anchor = c.NORTHWEST;
+		c.gridx = 2; c.gridy = 2; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST;
 		configPanel.add(this.removeLargeObjectsSize, c);
 
 		c.gridx = 0; c.gridy = 3; c.gridwidth = 1;
 		configPanel.add(this.removeParallelSegmentsCheck, c);
-		c.gridx = 1; c.gridy = 3; c.gridwidth = 1; c.anchor = c.NORTHEAST;
+		c.gridx = 1; c.gridy = 3; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHEAST;
 		configPanel.add(new JLabel("Max distance :"), c);
-		c.gridx = 2; c.gridy = 3; c.gridwidth = 1; c.anchor = c.NORTHWEST;
+		c.gridx = 2; c.gridy = 3; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST;
 		configPanel.add(this.removeParallelSegmentsTolerance, c);
 
@@ -323,8 +323,7 @@
 					public void actionPerformed(ActionEvent e) {
 						if (data!= null) {
-							LoadPdfDialog.this.placement.projection = null;
 							OsmBuilder.Mode mode = LoadPdfDialog.this.debugModeCheck.isSelected() ? OsmBuilder.Mode.Debug: OsmBuilder.Mode.Draft;
 							LoadPdfDialog.this.fileName = newFileName;
-							LoadPdfDialog.this.makeLayer(tr("PDF file preview"), mode);
+							LoadPdfDialog.this.makeLayer(tr("PDF file preview"), new FilePlacement(), mode);
 							LoadPdfDialog.this.loadFileButton.setText(tr("Loaded"));
 							LoadPdfDialog.this.loadFileButton.setEnabled(true);
@@ -336,16 +335,31 @@
 	}
 
-
-	private void okPressed() {
-
+	
+	private boolean preparePlacement()
+	{
 		boolean ok = this.parsePlacement();
 		if (!ok){
+			JOptionPane.showMessageDialog(Main.parent, tr("Problems parsing placement."));
+			return false;
+		}
+		
+		String transformError = this.placement.prepareTransform();
+		if (transformError != null){
+			JOptionPane.showMessageDialog(Main.parent, transformError);			
+		}		
+
+		this.savePlacement();
+		
+		return true;
+	}
+
+	private void okPressed() {
+
+		if (!preparePlacement()) {
 			return;
 		}
 
-		this.savePlacement();
-
 		//rebuild layer with latest projection
-		this.makeLayer(tr("Imported PDF: ") + this.fileName, OsmBuilder.Mode.Final);
+		this.makeLayer(tr("Imported PDF: ") + this.fileName, this.placement, OsmBuilder.Mode.Final);
 
 		this.setVisible(false);
@@ -353,8 +367,8 @@
 
 	private void savePressed() {
-		boolean ok = this.parsePlacement();
-		if (!ok){
+
+		if (!preparePlacement()) {
 			return;
-		}
+		}		
 
 		java.io.File file = this.chooseSaveFile();
@@ -362,10 +376,10 @@
 		if (file == null){
 			return;
-		}
-
-		this.savePlacement();
-
+		}		
+		
 		//rebuild layer with latest projection
 		this.removeLayer();
+
+
 		this.saveLayer(file);
 		this.setVisible(false);
@@ -675,5 +689,5 @@
 
 
-	private void makeLayer(String name, OsmBuilder.Mode mode) {
+	private void makeLayer(String name, FilePlacement placement, OsmBuilder.Mode mode) {
 		this.removeLayer();
 
@@ -682,5 +696,5 @@
 		}
 
-		OsmBuilder builder = new OsmBuilder(this.placement);
+		OsmBuilder builder = new OsmBuilder(placement);
 
 		DataSet data = builder.build(this.data.getLayers(), mode);
@@ -707,5 +721,5 @@
 	}
 
-	private void saveLayer(java.io.File file) {
+	private void saveLayer(java.io.File file) {		
 		OsmBuilder builder = new OsmBuilder(this.placement);
 		DataSet data = builder.build(this.data.getLayers(), OsmBuilder.Mode.Final);
Index: applications/editors/josm/plugins/pdfimport/src/pdfimport/OsmBuilder.java
===================================================================
--- applications/editors/josm/plugins/pdfimport/src/pdfimport/OsmBuilder.java	(revision 24179)
+++ applications/editors/josm/plugins/pdfimport/src/pdfimport/OsmBuilder.java	(revision 24186)
@@ -35,6 +35,6 @@
 
 	public Bounds getWorldBounds(PathOptimizer data) {
-		LatLon min = placement.tranformCoords(data.bounds.getMinX(), data.bounds.getMinY());
-		LatLon max = placement.tranformCoords(data.bounds.getMaxX(), data.bounds.getMaxY());
+		LatLon min = placement.tranformCoords(new Point2D.Double(data.bounds.getMinX(), data.bounds.getMinY()));
+		LatLon max = placement.tranformCoords(new Point2D.Double(data.bounds.getMaxX(), data.bounds.getMaxY()));
 		return new Bounds(min, max);
 	}
@@ -62,5 +62,5 @@
 		for(Point2D pt: layer.points) {
 			Node node = new Node();
-			node.setCoor(this.placement.tranformCoords(pt.getX(), pt.getY()));
+			node.setCoor(this.placement.tranformCoords(pt));
 
 			target.addPrimitive(node);
