Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proj4js tests #200

Merged
merged 3 commits into from Feb 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -11,6 +11,8 @@
/build/src
/build/phantomjs-*-windows
/build/phantomjs-*-windows.zip
/build/proj4js-*.zip
/build/proj4js
/examples/*.json
/examples/*.combined.js
/examples/example-list.js
@@ -77,6 +77,10 @@
PLOVR_JAR = 'bin/plovr-eba786b34df9.jar'
PLOVR_JAR_MD5 = '20eac8ccc4578676511cf7ccbfc65100'

PROJ4JS = 'build/proj4js/lib/proj4js-combined.js'
PROJ4JS_ZIP = 'build/proj4js-1.1.0.zip'
PROJ4JS_ZIP_MD5 = '17caad64cf6ebc6e6fe62f292b134897'


def report_sizes(t):
t.info('uncompressed: %d bytes', os.stat(t.name).st_size)
@@ -338,8 +342,19 @@ def hostexamples(t):
t.cp('examples/example-list.js', 'examples/example-list.xml', 'examples/Jugl.js', 'build/gh-pages/%(BRANCH)s/examples/')


@target(PROJ4JS, PROJ4JS_ZIP)
def proj4js(t):
from zipfile import ZipFile
ZipFile(PROJ4JS_ZIP).extractall('build')


@target(PROJ4JS_ZIP, clean=False)
def proj4js_zip(t):
t.download('http://download.osgeo.org/proj4js/' + os.path.basename(t.name), md5=PROJ4JS_ZIP_MD5)


if sys.platform == 'win32':
@target('test', '%(PHANTOMJS)s', INTERNAL_SRC, 'test/requireall.js', phony=True)
@target('test', '%(PHANTOMJS)s', INTERNAL_SRC, PROJ4JS, 'test/requireall.js', phony=True)
def test(t):
t.run(PHANTOMJS, 'test/phantom-jasmine/run_jasmine_test.coffee', 'test/ol.html')

@@ -354,7 +369,7 @@ def phantomjs_windows_zip(t):
t.download('http://phantomjs.googlecode.com/files/' + os.path.basename(t.name))

else:
@target('test', INTERNAL_SRC, 'test/requireall.js', phony=True)
@target('test', INTERNAL_SRC, PROJ4JS, 'test/requireall.js', phony=True)
def test(t):
t.run('%(PHANTOMJS)s', 'test/phantom-jasmine/run_jasmine_test.coffee', 'test/ol.html')

@@ -25,6 +25,7 @@
<script type="text/javascript" src="jasmine-1.2.0/jasmine-html.js"></script>
<script type="text/javascript" src="phantom-jasmine/console-runner.js"></script>
<script type="text/javascript" src="jasmine-extensions.js"></script>
<script type="text/javascript" src="../build/proj4js/lib/proj4js-combined.js"></script>

<script type="text/javascript">

@@ -99,6 +99,33 @@ describe('ol.Projection', function() {
expect(point.y).toRoughlyEqual(52.4827802220782, 1e-9);
});
});

describe('Proj4js integration', function() {

it('allows Proj4js projections to be used transparently', function() {
var point = ol.Projection.transformWithCodes(
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
'GOOGLE',
'WGS84');
expect(point.x).toRoughlyEqual(-5.625, 1e-9);
expect(point.y).toRoughlyEqual(52.4827802220782, 1e-9);
});

it('allows new Proj4js projections to be defined', function() {
Proj4js.defs['EPSG:21781'] =
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
var point = ol.Projection.transformWithCodes(
new ol.Coordinate(7.439583333333333, 46.95240555555556),
'EPSG:4326',
'EPSG:21781');
expect(point.x).toRoughlyEqual(600072.300, 1);
expect(point.y).toRoughlyEqual(200146.976, 1);
});

});

});

goog.require('goog.array');