Thanks Jody

Following your advice, I *think* I have it working with the code below.

I find to correctly align with the many available 3575 base layers that I
need to apply a scale factor of half the circumference of the equator.
However, when I look at the excellent explanation here
http://gis.stackexchange.com/a/149466, I would have expected a scale factor
of 9,000,964.8m.

  "Since the authalic radius
<http://en.wikipedia.org/wiki/Earth_radius#Authalic_radius> of the WGS84
ellipsoid is 6,371,007.2 meters, *either (1) r = 12,742,014.4 meters or (2)
r = 9,009,964.8 meters* (for the hemisphere only)."

Do you know why this is please?  I'm a little nervous just putting magic
numbers into code without knowing why but I can't find any reasonable
explanation for this on the web.

Thanks again,
Tim


double r = 40075160;  // circumference of the equator in meters

// move world coordinates into positive space addressing, so the lowest is 0,0
AffineTransform translate= AffineTransform.getTranslateInstance(r/2, r/2);
double pixelsPerMeter = ((double)TILE_SIZE) / r;
AffineTransform scale=
AffineTransform.getScaleInstance(pixelsPerMeter, pixelsPerMeter);
// Swap Y to convert world addressing to pixel addressing where 0,0 is
at the top
AffineTransform mirror_y = new AffineTransform(1, 0, 0, -1, 0, TILE_SIZE);

// combine the transform, noting you reverse the order
AffineTransform world2pixel = new AffineTransform(mirror_y);
world2pixel.concatenate(scale);
world2pixel.concatenate(translate);

Point2D src = new Point2D.Double(p.getX(), p.getY());
Point2D tgt = new Point2D.Double();
world2pixel.transform(src,tgt);


On Tue, May 31, 2016 at 1:00 AM, Jody Garnett <[email protected]>
wrote:

> That is tricky as we have helper methods that work with a bounds, but
> bounds for a polar projection are not really the best fit. The bounds are
> kind of a shortcut to sorting out an affine transform - can you figure out
> an affine transform yourself and work from that?
>
> --
> Jody Garnett
>
> On 30 May 2016 at 07:02, Tim Robertson <[email protected]> wrote:
>
>> Hi folks,
>>
>> I am struggling with what I believe should be a fairly simple task and
>> hoping someone can be kind enough to point me in the right direction.
>>
>> I have coordinates in WGS84 and I wish to paint an image in an arctic
>> projection.  For various reasons I can't use Mapnik, Geoserver etc for
>> this, but do need to manually convert to pixel coords.
>>
>> I am able to convert the coordinates using this:
>>
>> CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
>> CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3575");
>> Point point = GEOMETRY_FACTORY.createPoint(new Coordinate(lat, lng));
>> MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, true); 
>> // lenient
>>
>>
>> I am struggling to convert those onto the "canvas" - i.e. given a 4096x4096 
>> world tile, locate the pixels on the tile for each coordinates.  I suspect I 
>> should be using something like the worldToScreenTransform to locate the 
>> pixel addresses within the image:
>>
>> AffineTransform t = RendererUtilities.worldToScreenTransform(...)
>>
>> But I can't work out how to use it, what envelopes are etc.
>>
>> Could anyone please point me at a code snippet, or give some advice?
>>
>> Thanks,
>>
>> Tim
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> What NetFlow Analyzer can do for you? Monitors network bandwidth and
>> traffic
>> patterns at an interface-level. Reveals which users, apps, and protocols
>> are
>> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
>> J-Flow, sFlow and other flows. Make informed decisions using capacity
>> planning reports.
>> https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
>> _______________________________________________
>> GeoTools-GT2-Users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>
>>
>
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to