A method of establishing fence in three dimensions
Technical field
The present invention relates to the method for establishing fence, especially a kind of side for establishing fence in three dimensions
Method.
Background technique
Geographical fence is to construct a virtual geographical frontier in space.Currently, traditional geographical fence
Technology is all one virtual geographical frontier of building in two-dimensional space, and is all based on two-dimensional map platform and encloses to generate
It the generation on column and is analyzed.In the three-dimensional environment for having elevation variation, fence will not only consider two-dimensional geographical ring
Border, it is also contemplated that influence of the variation of geographical elevation to geographical location.In two-dimensional space, fence is polygon by two dimension
Come what is established, two-dimentional exhibition method cannot express architectural environment in true three-dimension space, space landform etc. well for the drafting of shape
Image of the factor for two-dimentional geography fence border.For the fence under complicated geographical environment, it is traditional two-dimensionally
The dislocation of boundary position is easily caused during reason fence creation, and true three-dimensional space cannot be expressed in two-dimensional scene
In elevation fluctuations.In three dimensions, it needs to establish fence index by the polygon of identification user's input,
Whether the position where then judging space point data according to fence index is within fence, in the space Lai Jianli
Fence.
Summary of the invention
The method that one kind of the invention establishes fence in three dimensions is intended to provide one kind and establishes in three dimensions
The method of geography fence extends to traditional fence in three-dimensional space, establishes space electronic fence and indexes, and
The fence where point data is determined in space.Fence is established for true three-dimension space, and reliable method is provided.
The method scheme that one kind of the invention establishes fence in three dimensions is as follows:
The present invention, which first passes through, establishes fence index to judge the point data location in space, then establishes electronics
Fence boundary determines index to detect three-dimensional space geography fence border, finally to establish three-dimensional space fence
Fence where judging the point data in space by establishing fence index encloses to establish three-dimensional space electronics
Column includes 10 steps altogether, and which includes fence indexes to establish and fence judgement where point data.
Fence indexes the process established
Step 1: in three dimensions according to the polygon of user demand building index, and to polygon data according to grid
Change to be divided, obtains the corresponding multiple space lattices of polygon;
Step 2: in three-dimensional scenic, the corresponding grid of first step space lattice is obtained, and traverse point all in grid,
Index is established to it convenient for next step;
Step 3: in the three-dimensional scenic of foundation, according to the corresponding relationship between grid and polygon, establishing index file;
Step 4: in three-dimensional scenic, established index file being applied in the fence judgement of next step;
The process of fence judgement includes: where point data
Step 5: in three-dimensional scenic, the three-dimensional coordinate data for the spatial point inquired as required, to be counted to grid
It calculates.In calculating, according to the index file established in third step, to inquire the corresponding polygon of grid;
Step 6: obtaining one in the corresponding polygon of grid by inquiring, execute this by the way of traversal
Operation;
Step 7: determine whether the point in three-dimensional scenic is within the scope of the elevation of polygon by elevation, if
Within then jump to the 8th step, if continuing to execute the 9th step not within polygon;
Step 8: determining whether the point in three-dimensional scenic is located within the scope of the elevation of polygon by ray algorithm;Such as
Fruit then continues to execute the 9th step within, if jumping not within the scope of polygon and executing the tenth step;
Step 9: whether being located in polygon by the point judged in space, this polygon can be added to the result returned
Collection;
Step 10: judging that whether there is also the points not inquired also within the scope of polygon, are back to third if also
Step, and above-mentioned step 3 is repeated to step 9.If it is not, the result set of return is exported, as the electricity in three-dimensional space
Sub- fence;
Three-dimensional space geography fence border is detected by establishing fence edge determination index, altogether comprising four steps
It is rapid:
Step 11: a polygon A is drawn by graphics mode, which is determined by user;
Step 12: it is two-way to this polygon A or so to be deviated respectively by Δ (error in judgement) of distance, it obtains different
2 offset distances are all the polygon of Δ;
Step 13: 2 polygonal meshes that step 12 is obtained are at a polygon;
Step 14: the final polygon that step 13 obtains is created according to the process that fence above-mentioned index is established
Space lattice index;It is indexed eventually by space lattice, can detect the geography fence border of polygon A in space.
The method that one kind of the invention establishes fence in three dimensions is relative to the advantage of conventional art: passing through
It establishes fence index in space to judge fence where point data, and then establishes the fence in three-dimensional space, it is real
The basis for having showed fence foundation in three dimensions and having used.By creation space lattice index come in three-dimensional space
Geography fence border range is detected, and the input of user is simplified, realize for three-dimensional geography fence boundary it is accurate
Detection.
Detailed description of the invention
Fig. 1 is the fence index Establishing process figure of the embodiment of the present invention.
Fig. 2 is the flow chart of fence judgement where the point data of the embodiment of the present invention
Fig. 3 is the detection geography fence border flow chart of the embodiment of the present invention.
Specific embodiment
Attached drawing 1 is that the fence of the embodiment of the present invention indexes Establishing process figure, altogether includes 6 steps, existing details are as follows:
Step 100, input needs to establish the polygon of index;
Step 101, gridding processing is carried out to polygon data, obtains the corresponding multiple space lattices of the polygon;
Step 102, the corresponding grid of the polygon (traversal grid) is obtained, so that next step establishes index to it;
Step 103, the index relative between grid and polygon is established;
Step 104, judge whether the corresponding grid of the complete polygon of poll, if there are also grids to exist, jump to step
102, if grid has traversed completion, jump to step 105;
Step 105, the polygon inputted to step 100, which establishes grid index, to be terminated.
Attached drawing 2 is the flow chart of fence judgement where the point data of the embodiment of the present invention, altogether includes 8 steps.Now it is described in detail
It is as follows:
Step 200, input needs the space coordinate point P (x, y, z) inquired;
Step 201, grid is calculated according to P (x, y, z), the index that step 103 is established in one with reference to the accompanying drawings inquires grid pair
The polygon answered;
Step 202, the polygon (traversal polygon) in corresponding polygon is obtained;
Step 203, through elevation decision-point P whether within the scope of the elevation of polygon.If not, jumping to step
206;If so, continuing next step 204;
Step 204, through ray algorithm decision-point P whether within the scope of polygon.If not, jumping to step
206,;If so, continuing next step 205;
Step 205, decision-point P is to add this polygon to the result set returned in the polygon.
Step 206, judge whether that there is also the complete grid inner polygons of poll not to be polled to.If so, jumping to step
202;If not, continuing next step 207;
Step 207, the result set that return step 205 obtains.
Attached drawing 3 is the flow chart of the method for the detection three-dimensional space geography fence border of the embodiment of the present invention
Establishing process figure is indexed for the fence edge determination of the embodiment of the present invention, includes altogether four steps, is first described in detail
It is as follows:
Step 300: user inputs the polygon formulated (in example by taking rectangle as an example);
Step 301: being the offset operation of Δ (error in judgement) to this polygon or so two-way implementation distance, obtain 2 partially
Move the polygon (dotted portion) that distance is Δ;
Step 302: 2 polygons (dotted portion) that step 301 is obtained are merged into a polygon;
Step 303: space lattice index is established to the final polygon that step 302 obtains.Eventually by space lattice rope
Draw, using fence index establishing method above-mentioned, (step 100 to step 207) can detect polygon in space
Geography fence border.