Running JTS code in a web browser

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Running JTS code in a web browser

Alexandre Walter Pretyman
Hello all.

I spent a few hours this weekend porting JTS 1.10 to GWT. For those who don't know GWT (Google Web Toolkit), it is a web programming framework released by Google in which you develop in Java and it compiles and generates the corresponding JavaScript code. It manages to do so by emulating a good part of the Java Runtime Environment. However not all, for example, since web browsers have no file access, I had to strip out the classes which did file IO, because such classes are not emulated and I had to re-implement some of the code in the classes to make it compatible with GWT.

This effort was made because after a post in the GWT group, people started showing interest in using JTS with google maps, although while I was porting it, I noticed that not all can be ported with a one to one relationship, for example, JTS Polygons can have holes in them, while Google Maps Polygons (apparantly) can't.

Here is an example project I setup that does the buffer operation on the client (web browser) and sends it to a server through a RPC call, which merely clones it, and returns it, just to test Serialization in GWT : http://www.4shared.com/file/85146364/98e14118/jts4gwt.html it is 20 megs because it has all required libraries to run included - sorry, windows only for now, if you run other platform, you can try downloading GWT for your platform and swapping the libraries.
To run the example you have to import it in eclipse, click the down arrow beside the Debug button, choose Debug Configurations... and in the following dialog, choose JTS4GWT under Java Application on tree view on the left and click Debug. It might take a little while to start because it must compile all Java sources into JavaScript when it starts debugging, then 2 windows will open, one being the window of the web browser, with a google map and a button beneath it to test the buffer function on the client side.

With Martin Davis approval (and everyone else involved in making JTS) I would setup a jts4gwt project in SourceForge and continue the port (there is still work to do), also, with the project in SourceForge, whoever needs a function which is not implemented yet in the GWT version, can implement it and contribute.

Google Maps is not the only option in mapping for GWT, there is a binding for OpenLayers as well, so I think one could use JTS geometries with OpenLayers too.

Regards,
Alexandre Pretyman

_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Running JTS code in a web browser

Martin Davis
Excellent work, Alexandre.

Funnily enough, a colleague of mine suggested doing this exact
experiment just last week.  Can't beat that for turnaround time...  8^)

I think your idea of creating a new SourceForge project is excellent.  
Post to this list if you need technical assistance.

I look forward to seeing some performance metrics coming out....

Martin

Alexandre Pretyman wrote:

> Hello all.
>
> I spent a few hours this weekend porting JTS 1.10 to GWT. For those
> who don't know GWT (Google Web Toolkit), it is a web programming
> framework released by Google in which you develop in Java and it
> compiles and generates the corresponding JavaScript code. It manages
> to do so by emulating a good part of the Java Runtime Environment.
> However not all, for example, since web browsers have no file access,
> I had to strip out the classes which did file IO, because such classes
> are not emulated and I had to re-implement some of the code in the
> classes to make it compatible with GWT.
>
> This effort was made because after a post in the GWT group, people
> started showing interest in using JTS with google maps, although while
> I was porting it, I noticed that not all can be ported with a one to
> one relationship, for example, JTS Polygons can have holes in them,
> while Google Maps Polygons (apparantly) can't.
>
> Here is an example project I setup that does the buffer operation on
> the client (web browser) and sends it to a server through a RPC call,
> which merely clones it, and returns it, just to test Serialization in
> GWT : http://www.4shared.com/file/85146364/98e14118/jts4gwt.html it is
> 20 megs because it has all required libraries to run included - sorry,
> windows only for now, if you run other platform, you can try
> downloading GWT for your platform and swapping the libraries.
> To run the example you have to import it in eclipse, click the down
> arrow beside the Debug button, choose Debug Configurations... and in
> the following dialog, choose JTS4GWT under Java Application on tree
> view on the left and click Debug. It might take a little while to
> start because it must compile all Java sources into JavaScript when it
> starts debugging, then 2 windows will open, one being the window of
> the web browser, with a google map and a button beneath it to test the
> buffer function on the client side.
>
> With Martin Davis approval (and everyone else involved in making JTS)
> I would setup a jts4gwt project in SourceForge and continue the port
> (there is still work to do), also, with the project in SourceForge,
> whoever needs a function which is not implemented yet in the GWT
> version, can implement it and contribute.
>
> Google Maps is not the only option in mapping for GWT, there is a
> binding for OpenLayers as well, so I think one could use JTS
> geometries with OpenLayers too.
>
> Regards,
> Alexandre Pretyman
> ------------------------------------------------------------------------
>
> _______________________________________________
> jts-devel mailing list
> [hidden email]
> http://lists.refractions.net/mailman/listinfo/jts-devel
>  

--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Running JTS code in a web browser

Alexandre Walter Pretyman
Thanks Martin, guess I saved you some trouble then.

What kind of performance metrics you would like to see?

The project was setup last night: http://sourceforge.net/projects/jts4gwt/ source code is available though SVN and the tracker has already tickets which I will clear in my own spare time

Regards

On Mon, Feb 9, 2009 at 2:44 PM, Martin Davis <[hidden email]> wrote:
Excellent work, Alexandre.
Funnily enough, a colleague of mine suggested doing this exact experiment just last week.  Can't beat that for turnaround time...  8^)

I think your idea of creating a new SourceForge project is excellent.  Post to this list if you need technical assistance.

I look forward to seeing some performance metrics coming out....

Martin

Alexandre Pretyman wrote:
Hello all.

I spent a few hours this weekend porting JTS 1.10 to GWT. For those who don't know GWT (Google Web Toolkit), it is a web programming framework released by Google in which you develop in Java and it compiles and generates the corresponding JavaScript code. It manages to do so by emulating a good part of the Java Runtime Environment. However not all, for example, since web browsers have no file access, I had to strip out the classes which did file IO, because such classes are not emulated and I had to re-implement some of the code in the classes to make it compatible with GWT.

This effort was made because after a post in the GWT group, people started showing interest in using JTS with google maps, although while I was porting it, I noticed that not all can be ported with a one to one relationship, for example, JTS Polygons can have holes in them, while Google Maps Polygons (apparantly) can't.

Here is an example project I setup that does the buffer operation on the client (web browser) and sends it to a server through a RPC call, which merely clones it, and returns it, just to test Serialization in GWT : http://www.4shared.com/file/85146364/98e14118/jts4gwt.html it is 20 megs because it has all required libraries to run included - sorry, windows only for now, if you run other platform, you can try downloading GWT for your platform and swapping the libraries.
To run the example you have to import it in eclipse, click the down arrow beside the Debug button, choose Debug Configurations... and in the following dialog, choose JTS4GWT under Java Application on tree view on the left and click Debug. It might take a little while to start because it must compile all Java sources into JavaScript when it starts debugging, then 2 windows will open, one being the window of the web browser, with a google map and a button beneath it to test the buffer function on the client side.

With Martin Davis approval (and everyone else involved in making JTS) I would setup a jts4gwt project in SourceForge and continue the port (there is still work to do), also, with the project in SourceForge, whoever needs a function which is not implemented yet in the GWT version, can implement it and contribute.

Google Maps is not the only option in mapping for GWT, there is a binding for OpenLayers as well, so I think one could use JTS geometries with OpenLayers too.

Regards,
Alexandre Pretyman
------------------------------------------------------------------------

_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
 

--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel


_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Loading...