MapXtreme for Java Basic concepts

Source: Internet
Author: User

First, MapXtreme for Java major components:
A, Mapxtremeservlet
(1) Provide grid map service
(2) Provide vector map service
(3) Provide metafile data Service (tab property data)

B, MAPJ Object
(1) Manage the various states of the Atlas (map center location, map view, map coordinate system)
(2) MAPJ by forwarding customer requests to the Mapxtremeservlet service instance

C, renderers
Used to generate the components that return the client map data. There are four kinds: localrenderer, mapxtremeimagerenderer, Intra-servlet Container Renderer, composite Renderer.
Mapxtremeimagerender can produce map images remotely, including MAPJ applications and remote one Mapxtremeservlet instance communication, generating map images;
Localrender map output to java2d graphics2d objects, all render generated on the client, also known as the vector transmission of maps;
Intraservletcontainerrenderer do not need socket connection, so Mapxtremesevlet map directly back to the client;
Composite renderer divides the map into dynamic and static layers, and when you need to update the map, you can only update the dynamic layer, and the static layer is generated only once.

D, Data Providers
Data Providers Access map data in the MAPJ object, providing a variety of sources,
Like MapInfo, Tab,esri's shapefiles,oracle spatial.

Second, the basic structure diagram

Third, the installation of geographical servers

1. Download Address: Http://www.pbinsight.com/support/product-downloads/item/mapxtreme-java-edition-trial-version/KVQDMVY6IY
2, run install.exe files, with the normal installation of Windows under the same installation software.
After the installation is successful, the following files will be available under the installation directory
apache-tomcat-5.5 self-with Tomcat
Bin
Docs
Examples some of the columns
The jar package that Lib uses
Logs
3, the use of MapXtreme Java tools
The MapXtreme servermapxtreme server is the Web server that is used to generate the map, and that is the map server.
Start the map server from the "Start MapXtreme Server" in the menu bar.
Then, we can open IE to enter http://127.0.0.1:8080/in the address bar to access
We can see a lot of useful link information in the navigation bar on the left. It mainly includes the management of Tomcat, the description of API documents, and sample of map application.
MapXtreme Java Manager starts MapXtreme Java Manager by clicking "MapXtreme java manager-webserver" in the menu bar. Note: The MapXtreme Java Manager-webserver will not start properly until the map server is started.
MapXtreme Java Manager starts successfully, a management interface pops up


Four, build own Webgis application

(1) standard format map picture (*.GST, or *.mdf).

(2) write a simple servlet first to write a simple servlet, and later we will rewrite its Doget method to generate the map.
Copy the files from the/mapxtreme-4.8.2/lib/common in the installation directory and/mapxtreme-4.8.2/lib/server to the/web-inf/lib directory in your WEB application.
, and then start the Web server and access the servlet through the browser to see if it's working properly.

(3) to write the server-side code to generate the map this refers to the generated map of the service-side code refers to the Web server, the servlet response to client requests to generate picture information code,
Specifically refers to the code in the Doget () method that is overridden in the servlet. In particular, the code to generate the map is the code that we use to invoke the MAPJ API to send map requests to the map server;
Relative to the map server, we are writing the map service client code, the equivalent of Web applications, we write here is the service-side code.

Mymapservlet.java

Package com.mapbar.gis.mapxtreme;
Import Java.awt.Color;

Import java.io.IOException;
Import Javax.servlet.ServletConfig;
Import javax.servlet.ServletException;
Import Javax.servlet.ServletOutputStream;
Import Javax.servlet.http.HttpServlet;
Import Javax.servlet.http.HttpServletRequest;

Import Javax.servlet.http.HttpServletResponse;
Import Com.mapinfo.mapj.MapJ;
Import Com.mapinfo.mapxtreme.client.MapXtremeImageRenderer;
Import Com.mapinfo.util.DoubleRect;

Import Com.mapinfo.xmlprot.mxtj.ImageRequestComposer;

	public class Mymapservlet extends HttpServlet {private String geosetfile = "";

	Private String DataDir = ""; Private String Content_Type = "text/html;

	CHARSET=GBK ";

	Private String mimetype = "Image/gif";

	Private String Mapxtremeurl = "";

	Private Color imagecolor = Color.Blue;
	Public Mymapservlet () {super ();
	public void Destroy () {Super.destroy (); public void doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {doany (request, response); 
		public void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {
	Doany (request, response);
		public void Doany (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException { try {response.setcontenttype ("text/html;
			CHARSET=GBK ");

			Response.setcontenttype (mimetype);
			Servletoutputstream so = Response.getoutputstream ();
			Load map MAPJ MAPJ = INITMAPJ (); Create imagerequestcomposer (picture background, low, format information) Imagerequestcomposer IMAGERC = Imagerequestcomposer.create (MAPJ, 256, IMA
			Gecolor, mimetype);
			Create Imagerender mapxtremeimagerenderer renderer = new Mapxtremeimagerenderer (Mapxtremeurl);
			Generates a picture render object returns an image.
			Renderer.render (IMAGERC);
			Renderer.tostream (SO);
			Renderer.dispose ();
			So.flush ();
		Turn off output stream} catch (Exception ex) {ex.printstacktrace (); } public void init (ServletConfig config) throwsservletexception {super.init (config);
		Geosetfile = Config.getinitparameter ("Geosetfile");
		DataDir = Config.getinitparameter ("DataDir");
	Mapxtremeurl = Config.getinitparameter ("Mapxtremeurl");
		}/** * *@ load map/public MAPJ INITMAPJ () {MAPJ mymap = new MAPJ (); try {//Load data, you can load gst,mdf.
			Geosetfile:.gst file path, datadir:.tab file directory Mymap.loadgeoset (geosetfile, datadir, NULL);
		Generate Picture Dimensions mymap.setdevicebounds (new Doublerect (0, 0, 800, 600));
		catch (Exception e) {e.printstacktrace ();
	return mymap; }

}

Xml

<?xml version= "1.0" encoding= "UTF-8"?> <web-app version= "2.5" xmlns= "Http://java.sun.com/xml/ns/javaee" Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http ://java.sun.com/xml/ns/javaee/web-app_2_5.xsd "> <!--mapxtreme Map server's servlet configuration--> <servlet> < servlet-name>mapxtreme</servlet-name> <servlet-class> Com.mapinfo.mapxtreme.MapXtremeServlet </ servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> < Servlet-name>mxtj_image</servlet-name> <servlet-class> Com.mapinfo.mapxtreme.ImageHandlerServlet & lt;/servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet> <
			Servlet-name>mxtj_metadata</servlet-name> <servlet-class> Com.mapinfo.mapxtreme.MetadataHandlerServlet </servlet-class> <load-on-startup>3</load-on-startup> </servlet> <servlet> <servlet-name>mxtj_vector</servlet-name> <servlet-class> Com.mapinfo.mapxtreme.VectorHandlerServlet </servlet-class> <load-on-startup>4</load-on-startup
			> </servlet> <servlet> <servlet-name>MyMapServlet</servlet-name> <servlet-class> Com.mapbar.gis.mapxtreme.MyMapServlet </servlet-class> <init-param> <param-name>geoSetFile< /param-name> <param-value> D:\workspace\MapXtreme\data\hunan.gst </param-value> </init-param > <init-param> <param-name>dataDir</param-name> <param-value>d:\workspace\mapxtreme\da
			ta</param-value> </init-param> <init-param> <param-name>mapxtremeurl</param-name>

	<param-value> Http://localhost:8090/MapXtreme/servlet/mapxtreme </param-value> </init-param> </servlet> <servlet-mApping> <servlet-name>mapxtreme</servlet-name> <url-pattern>/servlet/mapxtreme</ url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>mymapservlet</ Servlet-name> <url-pattern>/servlet/MyMapServlet</url-pattern> </servlet-mapping> < welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app >


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.