MapXtreme Java: Improving Performance When Using a Database

by Minna Lunney

Anyone familiar with Java database connectivity (JDBC) knows that this powerful functionality often comes at a price, in the form of decreased application performance.  The steps required to retrieve information from a database (e.g. log in/connect, perform query, retrieve records, return records) tend to be more numerous and time-intensive than the steps required to retrieve the same information from a file stored on the local machine.

The following are performance-boosting tips specifically geared toward database interaction in MapXtreme Java.

Use Connection Pooling

Establishing a connection to a database takes time and resources.  A program that has to access a database several times is quickly bogged down if forced to create a new connection for each “trip.”  With a connection pool, you create database connections that are then recycled by your program and other users/processes that may need them.  For more information about connection pooling, please refer to Chapter 11 in the MapXtreme Java Developer Guide: http://reference.mapinfo.com/software/mapxtreme_java/english/4_8_2/dev_guide/MapXtremeJavaDeveloperGuide.pdf

Prior to following the directions in the above documentation, you will need to perform these steps to ensure MapXtreme Java can connect to your database:

1) Shut down the MXJ server and quit the Web/StandAlone Manager(s), if necessary.

2) Locate or download the appropriate JDBC driver for your database.  If the driver is in .zip format, change its extension to .jar.

3) Copy the database driver to the following locations:

- [MXJ_Home]/lib/client

- [MXJ_Home]/[Tomcat folder]/webapps/mapxtreme[ver]/WEB-INF/lib

4) Browse to [MXJ_Home]/bin. Modify both the StandAlone and Web .lax files to include your driver in the classpath (the lax.class.path variable at the top of the file).  Follow the same forward- and backslash convention that is used for the other .jar files in the classpath, and separate each entry with the proper delimiter.  As an example for Windows:

lax.class.path=C:\\MXTJ482/MapXtreme-4.8.2/lib/client;C:\\MXTJ482/MapXtreme-4.8.2/lib/client/ojdbc14.jar;C:\\MXTJ482/MapXtreme-4.8.2/lib/client/mxjclient.jar;

….

The changes will take effect the next time you start the Manager(s) and/or MXJ server.

Specify Table Metadata

When retrieving a map table from a database, MapXtreme Java requires some basic information about the table, such as its coordinate system, spatial column, and rendition columns (if any).  This information is referred to as “table metadata.”  If you don’t supply metadata, MapXtreme Java will query the MAPINFO.MAPINFO_MAPCATALOG table in your database to obtain it, which adds to the time and resources required to retrieve the database table.

There are two ways to manually provide MapXtreme Java with the table’s metadata.  If you’re accessing the table through the MapXtreme Java Manager’s Add Layer Wizard, you can supply the metadata on the “Specify Other Table or Query Information” screen.  Click Use the following settings and fill in as many of the fields as possible before clicking Next.

java1

Programmatically, you can provide metadata to the constructor of the TableDescHelper.  For example:

// Table information
String[] idColumns = {"mi_prinx"};
String table = "States";
boolean bUseQuotes = false;
String spatialCol = "GEOLOC";
String rendCol = null;
RenditionType perFeatureType = RenditionType.none;
String labelRendCol = null;
RenditionType perFeatureLabelType = RenditionType.none;
CoordSys csys = CoordSys.longLatWGS84;
int dimensions = 2;
String owner = "mary";
// Create a TableDescHelper
OraSoTableDescHelper tableTDH = new OraSoTableDescHelper(table,
 bUseQuotes, idColumns, spatialCol, rendCol, perFeatureType,
labelRendCol, perFeatureLabelType, csys, dimensions, owner);

Use Zoom and Visibility Constraints

By default, when displaying a map layer, MapXtreme Java will retrieve all records from the table, even if you are only viewing a portion of the layer.  Every time the map is operated on- pan, zoom in/out- MXJ will again retrieve all the features from the table before rendering the modified view.  When the map layer comes from a database, this can result in slow performance as potentially hundreds or thousands of records are returned each time the map is manipulated.  By setting zoom constraints on a layer, you limit MXJ to retrieving just those records that fall within the specified zoom range, and to retrieving no records if the map layer is not visible within a given map view.

Within the MapXtreme Java Manager, you can adjust zoom constraints by selecting the database layer within Layer Control, and clicking the Display button.  On the tab that appears, check Display within Zoom Range, enter the desired visibility range and distance units, and click OK.

java3

Programmatically, you can use the following methods of the FeatureLayer class to control a database layer’s visibility:

FeatureLayer dbLayer = (FeatureLayer) myMapJ.getLayers().get(“DB_LAYER”);
dbLayer.setZoomLayer(true);
dbLayer.setMinZoom(new Distance(0, LinearUnit.mile));
dbLayer.setMaxZoom(new Distance(10, LinearUnit.mile));

Use QueryParams – Retrieve Only the Attributes You Need

When performing a search against a database table, the QueryParams class gives you control over the type and quantity of data retrieved.  For example, you may only need to retrieve the value of the “Name” column for each feature, in which case returning all columns and geometries would be overkill.  You can specify your search as attribute-only, geometry-only, or some combination thereof.  The more specific you make your return criteria, the better the search will perform.  For more information about the use of this class, please refer to Chapter 12 of the MXJ Developer Guide:

http://reference.mapinfo.com/software/mapxtreme_java/english/4_8_2/dev_guide/MapXtremeJavaDeveloperGuide.pdf

Also helpful are the MXJ Javadocs: http://reference.mapinfo.com/software/mapxtreme_java/english/4_8_2/docs/api/index.html

Use Pass-Through Queries – Retrieve Only the Records You Need

When loading a database table, you can limit which features and attributes are retrieved with the use of a pass-through query.  For example, SELECT ID, Name, MI_GEOMETRY, Population FROM myuser.world WHERE Population > 100000000.

When using the MapXtreme Java Manager, a pass-through query can be specified within the Add Layer Wizard:

java4

Programmatically, a query can be defined within the constructor for the table’s TableDescHelper:

String sql = "SELECT SW_MEMBER, Longitude, Latitude, FROM Addresses WHERE Outfirm='OFFICE BLDG'";
CoordSys coordsys = CoordSys.longLatWGS84;
String[] idColumns = {"SW_MEMBER"};
XYTableDescHelper xyTDH = new XYTableDescHelper(sql,
 idColumns, "Longitude", "Latitude", null, RenditionType.none,
null, RenditionType.none, coordsys);

For more information, see Chapter 12 in the MXJ Developer Guide: http://reference.mapinfo.com/software/mapxtreme_java/english/4_8_2/dev_guide/MapXtremeJavaDeveloperGuide.pdf

Use QueryBuilders

If you wish to search a database table that has been defined by a pass-through query (as discussed above), you must associate an instance of the QueryBuilder class with the table.  The QueryBuilder can refine your search and limit the amount of information that is retrieved.  Sample QueryBuilder classes are provided in the examples/client/querybuilders directory on a default MXJ install.  You can use these classes directly, or implement your own QueryBuilder class to suit your specific needs.  More information is available in Chapter 12 of the MXJ Developer Guide:

http://reference.mapinfo.com/software/mapxtreme_java/english/4_8_2/dev_guide/MapXtremeJavaDeveloperGuide.pdf

Use Database Indexes

Creating indexes within the database from which mapping data will be retrieved will improve the performance of all database operations.  For instructions on creating an index, please consult the documentation for your specific database(s).

Keep Layers Simple

Tables with complex geometries will be more resource-intensive than tables that contain simpler geometries.  If possible, use MapInfo Professional to perform snap/thin operations on complex features before uploading a table to your database.  Directions for feature thinning in MapInfo Professional can be found in this Knowledge Base document: http://testdrive.mapinfo.com/techsupp/miprod.nsf/kbase_by_product/C04149D2C49B7AE185256AAB006E0349

For more information on how MapInfo Professional can be used to streamline tables, please refer to the MIPro User Guide: http://reference.mapinfo.com/software/mapinfo_pro/english/10/MapInfoProfessionalUserGuide.pdf

MapInfo Professional: Creating Seamless Layers

by Minna Lunney

Seamless layers allow you to treat several map layers as one for purposes of labeling and changing display attributes.  They are especially convenient when used to combine large numbers of related TAB files.  For instance, one could combine 50 individual state highway layers into a single, seamless highway layer for the United States.  The individual layers will still exist as separate entities; the seamless layer simply points to the individual layer files, and does not override or merge them in any way.

Note: For best results, the seamless layer and all constituent layers should reside within the same directory.

Here’s how to create a seamless layer:

1) In MapInfo Professional, open all of the layers you wish to use for your seamless layer.  Use Layer Control to add them all to one map window.  In this example, we’re using parks layers for New York, Pennsylvania, and Ohio.

Seemless layer blog 1

Seemless layer blog 2

2) In the top menu bar, go to Tools > Tool Manager.  Find the Seamless Table Manager tool.  Check Loaded and Autoload, if not already checked, then click OK.

Seemless layer blog 3

3) Go to Tools > Seamless Manager > New Seamless Table.  Name and save the seamless layer to the same directory where the constituent tables reside

Seemless layer blog 4

The newly created seamless layer looks like any other TAB file, but as mentioned, it acts as a pointer to the data contained in the constituent tables.  This is evident when you compare the file sizes of the different tables.  The seamless table won’t be nearly as large as any of its constituent tables.

Seemless layer blog 5

Seamless layers can also be used in programs other than MapInfo Professional, such as MapXtreme Java and MapXtreme .NET.  For more information about seamless layers, please consult the MapInfo Professional User Guide:

http://reference.mapinfo.com/software/mapinfo_pro/english/10/MapInfoProfessionalUserGuide.pdf

Online Video Tutorials & Training

By Chris Brigger, Global Training Content Manager

Many customers have told us that budgets for travel and training are shrinking, making alternative training methods important.  In response, the PBBI Education Department is working on developing a series of online tutorial video clips. The short clips focus on a specific task or feature of various aspects of our software.

Our first series of online tutorials were posted to support the launch of MapInfo Professional version 10, and focus on the new user interface elements. These can be located online at: http://www.pbinsight.com/support/training/video-tutorials/. In the coming months, we will expand our online library to include tutorials for additional PBBI products.

PBBI’s Insights User Conference

Insights User Conference website is live – Register before 12/31 to get $200 off registration fee – http://insights10.pbbusinessinsight.com/

Development Tips from our Experts!

MapXtreme Java 4.8.2: Improving rendering quality

by: Minna Lunney

Obtaining the best looking maps possible starts with high-quality vector data and rasters, but is also heavily influenced by the rendering engine and style settings.  Below are a couple of simple tricks you can use within MapXtreme Java to enhance the quality of maps displayed on screen or saved as an image.

Enable Anti-aliasing

Anti-aliasing adds gray or colored pixels to blend with the original pixels within an image, resulting in lines and edges that are less jagged. This feature can be enabled within the Web and StandAlone Managers, as well as within your Java programs.

To use anti-aliasing with the MXJ Manager (Web or StandAlone), follow these steps:

1) Browse to [MXJ_Home]/bin and open MapXtremeJavaManager-Web.lax or MapXtremeJavaManager-StandAlone.lax for editing.

2) Add the following lines to the end of the LAX file:

#

# ENABLE ANTI-ALIASING

#

lax.nl.java.option.additional=-Dcom.mapinfo.render.quality=true

3) Save and close the LAX file.

Within an MXJ program, you can direct your ImageRequestComposer object to use anti-aliasing with the following line of code:

myImageRequestComposer.setRendering(Rendering.QUALITY);

Below are screenshots that illustrate the difference anti-aliasing makes.

Without anti-aliasing:

Without Anti-Aliasing

Without Anti-Aliasing

With anti-aliasing:

With Anti-Aliasing

With Anti-Aliasing

Adjust line caps and joins

This is a technique for maps that contain line features, such as highways.  Line renditions share a number of properties, but two in particular are of interest here: stroke-linecap (what the ends of a line segment should look like) and stroke-linejoin (what the line should look like at the junction of two segments).

Here are the available stroke-linecap options:

available stroke-linecap options

available stroke-linecap options

Here are the available stroke-linejoin options:

Screenshot 6

By default, MXJ line styles will use “butt” for stroke-linecap and “miter” for stroke-linejoin.  This may lead to jagged roads, especially at higher zoom levels.

Screenshot 4

To remedy this, open the MDF for the map in a text editor.  Find every instance of the words “miter” and “butt,” and replace them with the word “round.”  For example, the following style tag:

<style fill-opacity=”1.0″ stroke=”#990000″ stroke-opacity=”1.0″ stroke-width=”2.0″ stroke-linejoin=”miter” stroke-linecap=”butt” stroke-dasharray=”none” marker-continuous=”none” parallel-line=”none” symbol-mode=”font” symbol-foreground-opacity=”1.0″ symbol-background-opacity=”1.0″ />

Would be changed to this:

<style fill-opacity=”1.0″ stroke=”#990000″ stroke-opacity=”1.0″ stroke-width=”2.0″ stroke-linejoin=”round” stroke-linecap=”round” stroke-dasharray=”none” marker-continuous=”none” parallel-line=”none” symbol-mode=”font” symbol-foreground-opacity=”1.0″ symbol-background-opacity=”1.0″ />

Once this is done, save and close the MDF, then try rendering it again.  You should see that the lines are much smoother.

Screenshot 5

Here are the available stroke-linejoin options:

Getting on the Same Map

By Chris McCartney, Global Product Manager – Stratus

Consumers have become increasingly dependent on mapping applications ever since MapQuest went online in 1996. Today, maps are incorporated into search engines, company Web sites and according to a recent Forrester survey, nearly a third of North American adults own their own map-driven navigation device.

Developers took full advantage of open source technology when code for Google Maps API became available in 2005. The simplicity of Google and alternatives such as Bing Maps made it easy for organizations to provide customers with simple, intuitive Web-based mapping services.

Meanwhile, managers in back-office operations shied away from these basic mapping tools because they simply could not support the complex data crunching and spatial analysis necessary to make smart business decisions. Business-focused solutions (such as our own MapInfo Professional) delivered the advanced location intelligence and predictive analytics necessary to underwrite risk, design networks and plan retail expansions.

More recently, however, new technology has closed the gap between consumer simplicity and back-office sophistication – giving companies the ability to leverage common mapping applications that can handle the heavy lifting with a smile.

From a customer relationship point of view, this adds a much-needed level of consistency. Now, information presented on Web sites can reflect the realities of how a company operates. Making such accurate, up-to-date mapping and spatial analysis available to consumers helps increase confidence and satisfaction. From an efficiency point of view, the ability to access a centralized database helps improve data quality and eliminate unnecessary redundancies.

Consider this real-life example:  after a hurricane, one UK insurance company experienced a wave of claims—some of which fell outside the path of the storm.  Rather than alienate customers with flat-out denials, the company updated their Web mapping using GIS information that geocoded the exact path of the hurricane. They applied a generous buffer zone, which eliminated any chance of error and invited claimants to double check themselves whether they really wanted to submit that claim. With the ability to see the same information that underwriters saw, many decided to “unsubmit” their request – saving the company time, money and hassles.

What’s special about these new technologies?  Plenty.  First, they are driven by the same sophisticated spatial analysis engines that companies have relied on for their most important decisions.  Through RIA and tiling, they offer an intuitive, out-of-the box experience that is as simple and stylish as any of the consumer-driven apps.  Built using open-source technology, developers can easily add to and adapt these solutions without the risks of a pure home-grown application.

So, are you interested in getting on the same map with you customers?  For more insights, check out the recap from our recent Stratus RIA Workshop.  We look forward to your thoughts…

Out in front of the GIS Wave

By Jon Winslow, Global Portfolio Director, Location Intellgence

When MapInfo began knocking on doors with the world’s first desktop GIS in 1986, few business managers understood the concept of geo-spatial analysis or the power of LI (location intelligence).

Today, GIS technology is pervasive in society. Thirty-one percent of Americans own a portable navigation device. iPhone apps use GPS coordinates to find nearby restaurants.  You can hardly find a business website that doesn’t provide a link to an online map and driving directions. And four years since its release, Google Earth has been installed on over 500 million machines.

As for the future, industry experts predict that the GIS market will grow 50% within the next five years.

For business analysts, IT heads and developers who have relied on sophisticated location intelligent solutions for years, this sudden burst of GIS activity in the consumer market has its pros and cons.

  • On the one hand, business executives and financial officers who must approve and fund LI initiatives have personal experience with mapping and spatial analysis.  Discussions can quickly move from concept to concrete application as everyone has some familiarity with the underlying technology.
  • On the other hand, these same executives think they know what location intelligence is based on their experience with simple consumer applications – they often don’t understand what could be done with a business-strength solution.  After all, you can just download maps for free, correct?

Professionals understand that location intelligent technology does not necessarily equate to business intelligence.  So in a world where a bit of information can be dangerous, GIS experts must in some cases work harder to demonstrate the value of their work.

A few weeks ago, I had the pleasure of speaking with many such professionals at the AGI GeoCommunity conference in the United Kingdom.  When you are around people who understand that the hot, new “find the nearest” app making headlines today is really ho-hum ten-year-old technology, it gets you that much more energized about the leading-edge innovations that are making spatial analysis so much more valuable to business today.

These experts, who are out in front of the current GIS wave, have their eye on emerging technologies and incremental improvements that provide significant advantages. Depending on their role and responsibilities, business users are excited about what today’s advanced technology can deliver: more power, greater simplicity, increased flexibility and greater control.

  • The Professional. High-end users that need to create and analyze data see 3-D visualization as a potent tool, especially when you can combine satellite imagery with complex, proprietary geo-data. The ability to instantly access and analyze stores, markets and trading areas – overlay large number of polygons – and color code areas based on revenue, demographics, proximity and penetration, for example, generates insights that lead to better, more profitable decisions. In a word, they are excited about the power.
  • The Enterprise Planner. As business intelligence takes on a more important role across business functions, everyone is looking for fast, effective ways to install Web solutions.  Today’s newest technologies are driven by the same sophisticated spatial analysis engines that companies have relied on for their most important decisions.  Through RIA and tiling, they offer an intuitive, out-of-the box experience that is as simple and stylish as any of the consumer-driven apps.  Providing user-friendly access to complex LI tools is only getting easier.

  • The Developer. Individuals responsible for custom solutions and LI augmentation see advances in both functionality and flexibility. While some developers are loyal to their favorite API, they are finding that more advanced geo-spatial programs are being created to fit their expertise. Built using open-source technology, developers can easily add to and adapt these solutions without the risks of a pure home-grown application. In practice, that means a simple API designed to route trucks, for example, can be easily enhanced, edited, data-enabled or embedded into desktops and mobile devices.
  • The Data Manager. As 70% of all business data contains a geographic component, data stewards are looking for ways to help people access high volumes of geo-data without losing control. Now, location intelligence solutions make it easy to access data where it is stored, whether that’s Oracle, SQL Servers, flat files, etc., and users can manage, access and administer information through queries that do not disrupt the underlying data integrity or governance principles.

While these emerging technologies and incremental improvements mean little to the soccer mom who simply needs directions to the next away game, the value of true location intelligence has never been more appreciated than today.  For organizations dealing with complex challenges, this additional power, simplicity, flexibility and control translates into lower costs, improved customer satisfaction and profitable growth.

Are you out in front of the GIS wave?  Learn more about the latest solutions – and be sure to let us know what trends, technologies and applications interest you most.


Hear Solution Architect Jeremy Peters Discuss App Dev, Network Planning and Other Available Services

COMMS USER GROUP — WEDNESDAY NOVEMBER 18

—————————————————-

Pitney Bowes Business Insight at Your Service

Register Now

https://pbinsightevents.webex.com/pbinsightevents/onstage/g.php?t=a&d=661618038

Looking for ways to better understand, connect and communicate with your customers?

Our services organization can help — with everything from custom application development…to coverage location services…to pre-qualification and provisioning…to network planning and much more.

Be sure to attend this informative webinar with Solution Architect Jeremy Peters for a better understanding of all the services available from Pitney Bowes Business Insight in the areas of location intelligence, predictive analytics, operational intelligence and communication management.

Equipping Google & Bing for heavy-duty lifting

At this year’s insights ’09 user conference, we shared the stage with Microsoft and demonstrated how organizations can “power up” their Bing Maps to make better decisions using spatial analysis.

Developers were particularly interested in learning how our MapXtreme® software development kit turned the maps generated through Bing and Google into powerful business tools. In a sense, making it easy for developers to transform cartographic images into true location intelligence.

While there are clear advantages to comprehensive desktop applications such as MapInfo Professional, Web 2.0 does provide an environment where you can interact and modify your map tile images instantly. So it’s not surprising that the use of low-cost, web-generated imagery offered through Bing Maps (formerly Virtual Earth) and Google is common.

What’s missing from Bing and Google? Two things. Your data and a powerful analytics engine. That’s where MapXtreme comes into play. No matter how much you can accomplish in a browser, you need to do more if you want to make decisions that will advance your business.

Consider a retailer choosing a site for their next location. After you plot in your existing sites, you may want to overlay competitors, customers, market demographics, use SQL JOIN clauses, create buffers, run point-in-polygon analyses and more—that’s where middleware and enterprise mapping comes in to play.

SDKs like MapXtreme allow you to integrate your own data and conduct complex spatial analysts. A tile-based Rich Internet Application architecture ensures that map retrieval is fast, client side interactivity high, and server-side processing reduced.  Designed for enterprise use, the tile-based approach provides for the navigation of sophisticated quantitative data in a consistent and intuitive manner—without sacrificing cartographic quality.

Tile servers are becoming increasing popular for web mapping because they allow the application to pre-render parts of the map and store them as images. The ability to combine web, proxy and private caches based on site and user needs provides developers with many options and possible configurations.  In other words, with the right tools your favorite mapping applications can now do the heavy lifting needed to solve today’s complex business challenges.

For more information on MapXtreme please download our free eval at:

http://www.pbinsight.com/welcome/mapxtreme7

AGI GeoCommunity – Inspiration hub

Inspiration_hubFor those of you attending the UK AGI GeoCommunity 2009 event, come see us at our Inspiration Hub!

Take the opportunity to meet with Pitney Bowes Business Insight (PBBI) industry specialists and technology experts at GeoCommunity 09 in an informal, ‘drop-in’ style clinic. Discuss issues, share ideas, raise questions, or solve problems. Learn more about, product roadmaps, specific product features or new functionality, application development or systems integration.

This casual environment allows customers to meet and network on a 1:1 basis with individuals who have first hand knowledge of their markets, business needs and challenges.

Specific products to be showcased through the Inspiration Hub include:

  • MapInfo Professional v10.0
  • Crime Profiler
  • Stratus
  • MapInfo MapXtreme
  • ThePitney Bowes Spectrum Technology Platform
  • Data Products including Data as a Service
  • Confirm
  • Geocoding

AGI_platinum