Here is a screen shot of the updated ribbon based atlas program including the mask option.
In the last blog we developed an atlas program to create A4 and A3 printable maps from tables and workspaces. We could further enhance the program by adding a mask facility. The code for the mask was originally developed by Egge-Jan Pollé. Here is a screen shot of the updated ribbon based atlas program including the mask option. If we now use the Canadian maps provided in the MapInfo Pro trial data folder we can see how the mask works. Here is a screen shot after the Mask Settings OK button is pressed. The Create Mask Settings dialogue box allows the user to select a Border style and Translucency level if the Create Mask Settings option is enabled. If the OK button is pressed with the default settings a map will be printed with the following border style. The translucency and border options are shown below:- Having clicked the OK button these settings will be reflected in the maps selected. If we choose the Atlas Example button a dialogue box appears. Her you can choose a table and a column for your map/s as shown in the next screenshot:- Clicking OK brings up the Default Settings dialogue box. Here you can make changes as required. Here is a screen shot of the dialogue box. Clicking on OK will bring up the Ribbon Based Atlas Sample Code dialogue box as shown in this screen shot. Having chosen one or more regions clicking on the Print button will produce output like the following screen shot. We could change the translucency level or the borders by clicking on the Mask button. The screen shot shows the proposed changes. Here is a screen shot of a printed map after making these changes to the border type. If you require a map without a mask you can do this by clicking on the Mask Settings button and deselecting the mask option. Here is a map created after deselecting the mask option:_
1 Comment
In the previous blog we looked at updating the PrintLayout program to a ribbon based interface in MapInfo Pro. As mentioned in that blog the PrintLayout program is an excellent template for creating an atlas program for MapInfo Pro. We need to make some changes to the code so that a number of extra features can be made available to potential users. For instance, we need to let the user have some means of updating the default settings for the company data. Also the user should be able to use different tables and workspaces with the atlas program. Here is a screen shot of the atlas code showing the ribbon interface set up in MapInfo Pro. The atlas program should be able to ascertain whether there are tables open when the Atlas Example button is pressed. As shown in the next screen shot. If the user opens one or more tables the program will then open a dialogue box to let the user choose a layer and an associated column as shown in the following screen. Here three tables have been opened using the USA data from the MapInfo trial data. The user has selected the States table and the corresponding State_Name column data, as shown in the next screen shot. Once the user clicks OK the Default Settings dialogue box appears. This contains the basic organisation information for input into the completed maps. Here is a screen shot of the dialogue box. Note that each element can be updated for this session. When the user clicks OK the MLB dialogue box appears which contains all the relevant States in the USA States map. Here the user can choose one or more States to create individual maps of selected States. Clicking on Georgia and clicking on the Print button, as shown in the next screen shot, starts the map creation process. Clicking on the Print button will create the following map into the Output folder. When the user needs to exit the program clicking on the Info button produces the following dialogue box. So by adding some additional modules to the original program we have been able to create an atlas program which can be used with both individual tables and workspaces. Additionally the maps can be printed with an organisations’ details. As mentioned in previous blogs, in order to create this atlas ribbon based program within MapInfo Pro, we first need to create a definition file, relevant modules and a project file. Here is the code for the definition file: '************************************************************************************
'** Project Atlas '** '** Definition file '** '** Author: Joseph Short '** Date: 14 September 2017 '** Version: AppVersion (see below) '************************************************************************************ Include "MAPBASIC.DEF" Include "ICONS.DEF" Include "MENU.DEF" Declare Sub Main Declare Sub End_Program Declare Sub Endhandler Declare Sub InputAtlasDefaultSettings Declare Sub MLB Declare Sub CreateMaps Declare Sub LayoutPortrait Declare Sub LayoutLandscape Declare Sub MLBOKButton Declare Sub SelectAllFromMLB Declare Sub HighLightSelectedRegions Declare Sub PopulateRegionsArray Declare Sub DlgHandler Declare Sub Atlas_dialog Declare Sub AddMaps Declare Sub DialogHandler Declare Sub AtlasAbout Declare Function LongDate(ByVal dDate As Date) As String 'Function to check whether a table is open or not Declare Function TableIsOpen (ByVal sTabName As String) As Logical ' ///// Class "MBExtensions.MBDateAndTime" ///// ' Allows you to retreive information from a MapBasic Date (i.e. YYYYMMDD) or ' DateTime (i.e. YYYYMMDDHHMMSSFFF) string ' Convert the string to it's equivalent long date string representation ' (depends on Control Panel > Regional and Language Options) Declare Method RegionalLongDate Class "MBExtensions.MBDateAndTime" Lib "MBExtensions.dll" (ByVal sDateString as string) As String Define AppName "Ribbon Based Atlas Sample Code" Define AppVersion "0.70" Define MLBID 1001 Define SelectAllMLBID 1002 'Defining Dialog Width and Height 'This allows you to specify with and height clauses in terms of characters (i.e., Width 30dW, Height 10dH). Define dW *4 'Four dialog units equals one character in width Define dH *8 'Eight dialog units equals one character in height Global tTime as Time Global dDate as Date Global sTabFile, sTable, sColA, sColB, sRegionsArray(), sAddressArray(5), sPrintDate, sCopyrightText As String Global sFont, sRegion, sRegionTitle, sPrinterName, sDocTitle, sPapersize, sOutputFolder as String Global iRegionsSelectedArray(), iPaperChoice, iPapersize, iLogoWindowID, iMapWindowID, iLayoutWindowID As Integer Global iLayoutFontSize1, iLayoutFontSize2, iLayoutFontSize3, iLayoutFontSize4, iOrientation as Integer Global fZoom, fMp, fPaper1, fPaper2, fPaperWidth, fPaperHeight, fHorizontalDistance, fVerticalDistance, fPos1, fPos2 As Float Global lRegionObjectsSelected As Logical The PrintLayout program provided by Egge-Jan Pollé on his website is a code sample which iterates through polygons in a map in order to create individual maps from a selection of departmental polygons. This code has the potential to be updated into an atlas like program for general use within MapInfo Pro. As a first step let’s review what the PrintLayout offers in functionality terms. If you download and extract the folders you are given both the .mb and .mbx files together with folders and a map of France. The screen shot below shows the make up of the files. The MBExtensions.dll provides extra date functionality regarding date formats and there is an explanation within the code concerning this option. There are two folders Output and Tables. The code puts any created maps into the Output folder. The Tables folder contains a map of France. If you run the program in any recent version of MapInfo Pro the program will still run, but as legacy code as shown in the following screen shot:- The program has a menu based interface which can be updated to a ribbon interface as will be shortly shown. If you click on the first menu option provided by the Print Layout sample code a dialogue box checks to let the user save any open tables. A new map of France displays then a list box option appears as shown in the following screen shot. This MultiListBox option lists all the Regions of France and provides options to print a selection, or if required, all of them. There are also options to choose between A4 and A3 paper sizes. Selecting several Regions will result in the program automatically creating maps of the relevant departments for those regions. The maps will then be saved in the Output folder. Here is an example of the printout for Alsace. The first thing to note about this program is that all the information is hard coded. The program currently only works with a specific map of France and related data such as the company information which is already in written into the code. If you want to use a different map and update the company data then the program has to be re-compiled for the updates to take effect. So as mentioned before, this program is an excellent template for creating an atlas program but will need more than a ribbon interface for it to be viable for general use.
|
AuthorJoe Short BSc has been involved with various mapping solutions for over twenty years. If you are considering implementing a GIS or have ArcGIS Pro, MapInfo Pro or QGIS training requirements, jps services would be happy to be of assistance to your organisation. Archives
September 2023
Categories
All
|