POST(HTTP)
Return Floor Plan : http://ai.measuresquare.com/api/file
Return Outline: http://ai.measuresquare.com/api/outline
Use HTTP Basic auth.
We will provide a string format of user:pass
.
BASE64 encode the string.
Supply an Authorization header with content Basic followed by the encoded string.
For example:
The string 'user:pass' encodes to 'dXNlciUzQXBhc3M='
So that we should add "Authorization: Basic dXNlciUzQXBhc3M=" to request header
pixellength: scale, represents the length in fact of each pixel(by millimeter)
file: floorplan file
Json object,include 4 field:
area
: total area in square meterperimeter
: total perimeter in meterrooms
: a list of room object, each room have 4id
, area
(m2), perimeter
(m) and points
doors
: a list of door object, each door have 2id
and points
points
: a list of point object, each point have two
integer fieldx
,y
return data example:
{
area: xxxxx,
perimeter: yyyyy,
rooms:[
{
id: 1,
area: 11,
perimeter: 22,
points: [
{ x:x1, y:y1}, { x:x2, y:y2}, ...
]
},
{
id: 2,
area: 33,
perimeter: 44,
points: [
{ x:x1, y:y1}, { x:x2, y:y2}, ...
]
}
...
],
doors:[
{
id: 1,
points: [ { x:x1, y:y1}, { x:x2, y:y2} ]
},
{
id: 2,
points: [ { x:x1, y:y1}, { x:x2, y:y2} ]
},
...
]
}
import urllib2 url = 'http://ai.measuresquare.com/api/file' data = {'PixelLength':4} files = {'file':open(filepath, 'rb')} response = requests.post(url, data=data, files=files, auth=HTTPBasicAuth('user', 'pass'))
download python code by click here