# Graphic Processing
Graphic processing is generally implemented in two ways:
- Method 1: Compose into a new map with
composeNewMap
/**
* Compose into a new map
* @param param Compose parameters
* @return {Promise<any>}
*/
composeNewMap(param: IComposeNewMap | IComposeNewMap[]): Promise<any>;
/**
* Compose new map parameters
*/
export interface IComposeNewMap {
/** Map ID. */
mapid: string;
/** Map version (uses current open map version when empty). */
version?: string;
/** Map clip bounds, format [x1,y1,x2,y2]; empty means no clipping */
clipbounds?: [number, number, number, number];
/** Select contain or intersect (default false for contain, true for intersect) */
selByCrossing?: boolean;
/** Four parameters (x offset, y offset, scale, rotation in radians), optional, for final coordinate correction */
fourParameter?: [number, number, number, number];
/** Whether to use inverse four-parameter calculation, default false */
isInverseFourParamter?: boolean;
/** Layer names to display; empty means all layers */
layers?: string[];
/** Layer name prefix for the new map; if set to null, no default prefix. Without prefix, layer name conflicts may cause different rendering when layer attributes are set */
layerPrefix?: string;
/** Layer name suffix for the new map */
layerSuffix?: string;
/** Output file name; empty means auto-generated from parameters */
savefilename?: string;
/** Purge graphic data after generation to reduce DWG file size */
purge?: boolean;
/** When entities come from other maps, auto-rename block definitions if duplicated, default true */
isRenameBlockNameIfExist?: boolean;
/** Whether to zoom to extent after creation, default false (for multi-map merge, only set for the first map) */
isZoomExtents?: boolean;
/** CAD version for export. Use * for current CAD map version */
cadVersion?: string | "*" | "cad2000" | "cad2004" | "cad2007" | "cad2010" | "cad2013" | "cad2018";
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Example: Extract data from several layers of a CAD map and save as a new map
let svc = new vjmap.Service(env.serviceUrl, env.accessToken)
// js code
let res = await svc.composeNewMap({
mapid: "sys_zp",
vesion: "v1",
layers: ["red line", "road"]
})
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
- Method 2: Create a new map based on a template map
export class DbDocument {
/** Source map for modification or add/delete; format mapid/version, e.g. exam/v1 */
from?: string;
/** When from is set: select specified layers from source map; entities not in specified layers will not display */
pickLayers?: string[];
/** When from is set: select specified entity IDs from source map; entities not in specified IDs will not display */
pickEntitys?: string[];
/** When from is set: use expression to select entity IDs; union with pickEntitys results */
pickExpr?: string;
isClearFromDb?: boolean;
/** Document environment for settings like line width display; LWDISPLAY: true to show, false to hide line width */
environment?: Record<string, any>;
/** Entity set. */
entitys?: IDbEntity[];
/** Layer set. */
layers?: IDbLayer[];
/** Text styles. */
textStyles?: IDbTextStyle[];
/** Dimension styles. */
dimStyles?: IDbDimStyle[];
/** Linetypes. */
linetypes?: IDbLinetype[];
/** Block definitions. */
blocks?: IDbBlock[];
/** When entities come from other maps, auto-rename block definitions if duplicated, default true */
isRenameBlockNameIfExist?: boolean;
/** Whether to zoom to extent after creation, default false */
isZoomExtents?: boolean;
//... other methods omitted
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Example: Extract data from several layers of a CAD map and save as a new map
let svc = new vjmap.Service(env.serviceUrl, env.accessToken)
let doc = new vjmap.DbDocument();
doc.from = "sys_zp/v1";
doc.pickLayers = ["red line", "road"]
// js code
let res = await svc.updateMap({
mapid: vjmap.getTempMapId(),// Temporary map auto-delete time in minutes when not browsed. Default 30
filedoc: JSON.stringify(doc),
mapopenway: vjmap.MapOpenWay.Memory,
style: {
backcolor: 0 // If div background is light, set to oxFFFFFF
}
})
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
# Clipping Graphics
let svc = new vjmap.Service(env.serviceUrl, env.accessToken)
// js code
let res = await svc.composeNewMap({
mapid: "sys_zp",
vesion: "v1",
/** Map clip bounds, format [x1,y1,x2,y2]; empty means no clipping */
clipbounds?: [x1,y1,x2,y2];
})
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9

# Coordinate Transformation
let svc = new vjmap.Service(env.serviceUrl, env.accessToken)
// js code
let res = await svc.composeNewMap({
mapid: "sys_zp",
vesion: "v1",
/** Four parameters (x offset, y offset, scale, rotation in radians), optional, for final coordinate correction */
fourParameter?: [number, number, number, number];
})
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9

# Merging Graphics
// --Graphic processing to compose new graphics--Process graphic list, then compose into a new graphic
let svc = new vjmap.Service(env.serviceUrl, env.accessToken)
// Compose into new map: process sys_world, then merge with sys_hello to generate new map file
let rsp = await svc.composeNewMap([
{
mapid: "sys_world", // Map id
// Parameters below can be set as needed for layer, bounds, coordinate transformation
//layers: ["latlon labels","COUNTRY"], // Layer name list to display
//clipbounds: [10201.981489534268, 9040.030491346213, 26501.267379, 4445.465999], // Bounds to display
//fourParameter: [0,0,2,0] // Four-parameter transformation for the map
},
{
mapid: "sys_hello"
}
])
if (!rsp.status) {
message.error(rsp.error)
}
// Return result:
/*
{
fileid: "pefbe7459b06",
mapdependencies: "sys_world||sys_hello",
mapfrom: "sys_world&&v1&&&&0&&&&&&&&&&&&10||sys_hello&&v1&&&&0&&&&&&&&&&&&2",
status: true
}
*/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Graphic arrangement and composition example (opens new window)
# Extracting Layers
You can also use the layers parameter of composeNewMap to extract layers. Here DbDocument is used as an example: