Related
I am trying to sift through some free text answers on geographical locations. As one of the steps, I want to check if the answer is any of the 290 municipalities in my country. As 290 entries would make my code cumbersome/hard to read I try saving them in an array, like below:
Data resorTEST;
keep R_res_ort_namn R_res_ort_txt R_kom_lan R_kommun;
set resor1TEST resor2TEST resor3TEST;
R_res_ort_namn=strip(lowcase(R_res_ort_namn));
R_res_ort_txt=strip(lowcase(R_res_ort_txt));
R_kom_lan=strip(lowcase(R_kom_lan));
array kommuner{290} $ ("upplands väsby" "vallentuna" "österåker" "värmdö"
"järfälla" "ekerö" "huddinge" "botkyrka" "salem"
"haninge" "tyresö" "upplands-bro" "nykvarn" "täby"
"danderyd" "sollentuna" "stockholm" "södertälje" "nacka" "sundbyberg"
"solna" "lidingö" "vaxholm" "norrtälje" "sigtuna" "nynäshamn"
"håbo" "älvkarleby" "knivsta" "heby" "tierp" "uppsala"
"enköping" "östhammar" "vingåker" "gnesta" "nyköping" "oxelösund" "flen"
"katrineholm" "eskilstuna" "strängnäs" "trosa" "ödeshög" "ydre"
"kinda" "boxholm" "åtvidaberg" "finspång" "valdemarsvik" "linköping"
"norrköping" "söderköping" "motala" "vadstena" "mjölby" "aneby"
"gnosjö" "mullsjö" "habo" "gislaved" "vaggeryd" "jönköping"
"nässjö" "värnamo" "sävsjö" "vetlanda" "eksjö" "tranås"
"uppvidinge" "lessebo" "tingsryd" "alvesta" "älmhult" "markaryd"
"växjö" "ljungby" "högsby" "torsås" "mörbylånga" "hultsfred"
"mönsterås" "emmaboda" "kalmar" "nybro" "oskarshamn" "västervik"
"vimmerby" "borgholm" "gotland" "olofström" "karlskrona" "ronneby"
"karlshamn" "sölvesborg" "svalöv" "staffanstorp" "burlöv" "vellinge"
"östra göinge" "örkelljunga" "bjuv" "kävlinge" "lomma" "svedala"
"skurup" "sjöbo" "hörby" "höör" "tomelilla" "bromölla"
"osby" "perstorp" "klippan" "åstorp" "båstad" "malmö"
"lund" "landskrona" "helsingborg" "höganäs" "eslöv" "ystad"
"trelleborg" "kristianstad" "simrishamn" "ängelholm" "hässleholm" "hylte"
"halmstad" "laholm" "falkenberg" "varberg" "kungsbacka" "härryda"
"partille" "öckerö" "stenungsund" "tjörn" "orust" "sotenäs"
"munkedal" "tanum" "dals-ed" "färgelanda" "ale" "lerum"
"vårgårda" "bollebygd" "grästorp" "essunga" "karlsborg" "gullspång"
"tranemo" "bengtsfors" "mellerud" "lilla edet" "mark" "svenljunga"
"herrljunga" "vara" "götene" "tibro" "töreboda" "göteborg"
"mölndal" "kungälv" "lysekil" "uddevalla" "strömstad" "vänersborg"
"trollhättan" "alingsås" "borås" "ulricehamn" "åmål" "mariestad"
"lidköping" "skara" "skövde" "hjo" "tidaholm" "falköping"
"kil" "eda" "torsby" "storfors" "hammarö" "munkfors"
"forshaga" "grums" "årjäng" "sunne" "karlstad" "kristinehamn"
"filipstad" "hagfors" "arvika" "säffle" "lekeberg" "laxå"
"hallsberg" "degerfors" "hällefors" "ljusnarsberg" "örebro" "kumla"
"askersund" "karlskoga" "nora" "lindesberg" "skinnskatteberg" "surahammar"
"kungsör" "hallstahammar" "norberg" "västerås" "sala" "fagersta"
"köping" "arboga" "vansbro" "malung-sälen" "gagnef" "leksand"
"rättvik" "orsa" "älvdalen" "smedjebacken" "mora" "falun"
"borlänge" "säter" "hedemora" "avesta" "ludvika" "ockelbo"
"hofors" "ovanåker" "nordanstig" "ljusdal" "gävle" "sandviken"
"söderhamn" "bollnäs" "hudiksvall" "ånge" "timrå" "härnösand"
"sundsvall" "kramfors" "sollefteå" "örnsköldsvik" "ragunda" "bräcke"
"krokom" "strömsund" "åre" "berg" "härjedalen" "östersund"
"nordmaling" "bjurholm" "vindeln" "robertsfors" "norsjö" "malå"
"storuman" "sorsele" "dorotea" "vännäs" "vilhelmina" "åsele"
"umeå" "lycksele" "skellefteå" "arvidsjaur" "arjeplog" "jokkmokk"
"överkalix" "kalix" "övertorneå" "pajala" "gällivare" "älvsbyn"
"luleå" "piteå" "boden" "haparanda" "kiruna");
/*if not missing(R_res_ort_namn) then R_kommun=prxchange("s/^.*-(.* kommun)/$1/",1,R_res_ort_namn);
else if prxmatch("/^.*([a-zA-Z]*? kommun).*$/",R_res_ort_txt) then R_kommun=prxchange("s/^.*?([a-zA-Z]*? kommun).*$/$1/",-1,R_res_ort_txt);
else if prxmatch("/^.*([a-zA-Z]*? kommun).*$/",R_kom_lan) then R_kommun=prxchange("s/^.*?([a-zA-Z]*? kommun).*$/$1/",-1,R_kom_lan);
else */if R_res_ort_txt in kommuner then R_kommun=R_res_ort_txt;
run;
However, for some reason this does not seem to work for all of the municipalities. The municipality of "uppsala" works for instance, but not the municipality of "ängelholm".
I have tried stripping the variables of whitespace and converting everything to lowercase. What am I doing wrong?
Additional info:
For some reason it does work flawlessly if I skip the array and just copy-paste the exact same list of municipality names into a parenthesis following the in-operator. I would however need to repeat this step 5-6 times and this solution would make my code quite cumbersome.
You are defining the ARRAY
Array kommuner{290} $
with character length 8. See what happens when you fix that.
I am trying to decode an array of data from a piece of legacy equipment in to a more useful format.
I have the following base64 encoded string:
iWGLvgUjF73/tW0+EAZDvf+cYj6pPw+9YLFjPqYCnbzgvm4+BEYVvBvOfD4QtBi8zdSCPlI7lrzg
q4I+HYb1vMupfT5sbxm9iYxyPh3JGL3IIGs+onj6vBnhaT6yQa28UrNuPi01Xrx22nY+PZMvvMi2
fj5kJlu8/l+BPrdVo7wT64A+BjjfvL1SfD545QK9i191PiZXBL0Ts28+s/fnvKnobT4wb7K8zOpw
PlHyg7xGMXY+KsVQvHnXfD7EdF68z++APqVHlrxrT4E+kBvOvD21fj5wYf+8ItJ3PoZrCL1hBXE+
/VL8vF5MbT5hJcm8TXNuPi1FjbyPRHQ+asVFvDCTfD6mtT+8GrKBPgghibxLyII+z13NvKfagD7g
hAi900l5PttTGL356G8+8SMPvQxIaj5esd+8J/NqPugjkbzj/HE+pr0svGOmfD5K6Bi8pPqCPnOY
e7yIpYQ+tivYvMI7gj7xKBi9ipJ5Pu4oLr1MuW0+Y38jvdhgZj5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gi99AhnPjSf8rwZJ2M+7gi3vGTEZD7g
EWW8/zVrPkJ+BLzd7HM+5Dfku0Dgez4WUDm8Npd/PgXlnrybpn0+jUHmvJqVdj4ASgq9u2xtPhAT
DL3m7GU+b2XrvOJYYz5Ue6O84tZmPjYwNbxyoW8+tbm0u+yqej4Tk9S7HaWBPifMaLzwy4I+nb3U
vC6rfz4VTBi914NzPh/yLr2l82U+mPIhvRbwXD5Qmei8piVdPmqVXLxIgWc+/xRtuvcbeT4rYTE7
9EiFPviA27sgAIk+dp/bvJZEhD76FEW9hQJxPgmSa710iVg+uzJDvZ9tTj5gUru8euJZPld95zr4
PnQ+tKopPIbGhT4P+wu7FbSIPjMbz7ydN4M+V6wwvfxRdT62qES9Y9RnPmvWLb2ak2E+sGgEvWY0
Yj7zqLa8en9nPj/xeryF6G4+RHJHvKlbdj7xY1a80318Ppcpj7yRgX8+Py7IvLs7fj4iaQS9xHF4
PpxWHr3btW8+D3wnvSq+Zj6NLhm9jV1hPoaf77zwEGI+9MWavMR6aT4lkCy8F3N1PsR/CLzWd4A+
kHVrvCtGgz5v5tq8
When adding trailing padding and decoding this from base64, it produces an unknown binary format.
What I know so far based on limited inspection of the application:
It is definitely base64.
This array describes a series of floating point data (with values between 19 and 50) that consists of 201 points.
The application that created this was likely written in .NET.
How is this data encoded, and can you provide psuedo-code to decode it?
Update #1:
This data describes a return loss measurement waveform from an old network analyser.
The expected values above are based on what the instrument displays, and it is possible that they are calculated from real and imaginary components.
Update #2:
I've found there was also a CSV version of the data for this series. Expected values are:
28.6740250379346, 26.031723427971, 26.6849726930916, 27.5095233036572, 27.9755283611409, 28.0419902829292, 27.9918713318024, 28.0331481409078, 28.2620361924923, 29.1899991143532, 30.4746778667205, 31.9841888600965, 32.7562027026775, 32.2032446202011, 31.0251062040461, 30.1158617686259, 29.5968352710132, 29.8991302542384, 30.7711739051407, 32.5985879649759, 35.465787543584, 38.4033014264434, 36.2400347268325, 33.230539516557, 30.816214031517, 29.493776099706, 28.9641221620517, 29.3271399473768, 30.5497479471498, 32.9092924040263, 36.23602780908, 36.6766990656565, 32.9072309537322, 29.8008349575816, 27.8506153462939, 26.8255601987161, 26.7773337706284, 27.6450826739213, 29.6698279365727, 32.925219461411, 34.9915552473819, 31.6841927998324, 28.219566759529, 25.990640197895, 24.8525028738483, 24.6159871249645, 25.2752655673475, 26.9870507463537, 29.9877735491643, 33.2675296198038, 31.6015986278861, 27.8240493530138, 25.2742229688217, 23.9448603205908, 23.5140204346426, 23.9914986842046, 25.5009034820686, 28.1555920133881, 31.3075467263927, 30.7066273219751, 27.2707536503799, 24.7348022011574, 23.2637028240862, 22.7794008043094, 23.1669728824416, 24.5474786226331, 26.9949958437379, 30.2488348819328, 30.6013906923573, 27.3394012893084, 24.6326441335966, 23.0411076555662, 22.4181795795548, 22.7062561945124, 23.8692711954611, 26.163804153602, 29.606819207681, 31.2543679681834, 28.1493119289191, 25.0924674969376, 23.2520785937701, 22.4092737645517, 22.5015858777069, 23.4763598655373, 25.5208843109912, 28.9618678298617, 32.6403317308031, 30.3536019856501, 26.5991532707429, 24.2773569962831, 23.1127901052235, 22.9043583677862, 23.6093457155953, 25.3499073692444, 28.4637157202952, 32.8016120624956, 32.4896370664701, 28.3239184297021, 25.5279166849078, 24.0185490655501, 23.5330605365427, 23.8948677486768, 25.2054578354006, 27.7143031565687, 31.5869657438201, 33.7333955992785, 30.3948949895062, 27.1037601765126, 25.2161101159979, 24.3558529725873, 24.3231491126384, 25.2139427454679, 27.1233066134797, 30.3453761997478, 34.4047437237606, 33.8064220094595, 29.9215033359328, 27.3307978071688, 25.8801149514006, 25.4718657467003, 25.8501031953971, 27.1888665858689, 29.5756748124031, 32.9812339884177, 35.3068159226901, 32.6414213429246, 29.5799546795568, 27.7291120251878, 26.9050286745762, 26.9075167887431, 27.7591889971496, 29.3670540494547, 31.7578198149182, 33.5065256564295, 32.6776622084245, 30.4203840091006, 28.688025867147, 27.7417192975661, 27.4916484304414, 27.9791419175041, 29.2902681126682, 31.4107407957172, 33.4602036884894, 33.9200015192937, 32.1201008630103, 30.1453133278815, 28.7841082718969, 28.136959973426, 28.109171467367, 28.8259362791248, 30.0289196496445, 31.326134345957, 32.0708833202456, 31.4950426416152, 30.1423739250155, 29.0036769811377, 28.2190253962644, 28.1086422581195, 28.4750473325836, 29.1942813484775, 29.7608412256926, 29.6876433997282, 28.689538924267, 27.2407586615062, 26.0067421520125, 25.1638342823008, 24.8250524294419, 24.9395261449731, 25.4584143514754, 25.8777584307235, 25.6465050536004, 24.5707670056442, 23.0511544464452, 21.7615681906835, 20.9761497089273, 20.7854547053249, 21.2816973223554, 22.253260423558, 23.2052378948627, 23.4706372938485, 23.2944515491774, 23.1680235174658, 23.5290621578115, 24.4333231530622, 25.8639616096787, 27.9401749621508, 30.7364242326027, 33.9420488375473, 35.6377896682262, 33.4869702934454, 30.5820901568128, 28.3404467791117, 26.8270077060156, 26.0018669972732, 25.9446717292131, 26.5828002183748, 28.0360464264943, 30.0958735279379, 31.2921110009257, 29.5253906387702, 26.6971475290807
To advance the cause,
iWGLvgUjF73/tW0+EAZDvf+cYj6pPw+9YLFjPqYCnbzgvm4+BEYVvBvOfD4QtBi8zdSCPlI7lrzgq4I+HYb1vMupfT5sbxm9iYxyPh3JGL3IIGs+onj6vBnhaT6yQa28UrNuPi01Xrx22nY+PZMvvMi2fj5kJlu8/l+BPrdVo7wT64A+BjjfvL1SfD545QK9i191PiZXBL0Ts28+s/fnvKnobT4wb7K8zOpwPlHyg7xGMXY+KsVQvHnXfD7EdF68z++APqVHlrxrT4E+kBvOvD21fj5wYf+8ItJ3PoZrCL1hBXE+/VL8vF5MbT5hJcm8TXNuPi1FjbyPRHQ+asVFvDCTfD6mtT+8GrKBPgghibxLyII+z13NvKfagD7ghAi900l5PttTGL356G8+8SMPvQxIaj5esd+8J/NqPugjkbzj/HE+pr0svGOmfD5K6Bi8pPqCPnOYe7yIpYQ+tivYvMI7gj7xKBi9ipJ5Pu4oLr1MuW0+Y38jvdhg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wZJ2M+7gi3vGTEZD7gEWW8/zVrPkJ+BLzd7HM+5Dfku0Dgez4WUDm8Npd/PgXlnrybpn0+jUHmvJqVdj4ASgq9u2xtPhATDL3m7GU+b2XrvOJYYz5Ue6O84tZmPjYwNbxyoW8+tbm0u+yqej4Tk9S7HaWBPifMaLzwy4I+nb3UvC6rfz4VTBi914NzPh/yLr2l82U+mPIhvRbwXD5Qmei8piVdPmqVXLxIgWc+/xRtuvcbeT4rYTE79EiFPviA27sgAIk+dp/bvJZEhD76FEW9hQJxPgmSa710iVg+uzJDvZ9tTj5gUru8euJZPld95zr4PnQ+tKopPIbGhT4P+wu7FbSIPjMbz7ydN4M+V6wwvfxRdT62qES9Y9RnPmvWLb2ak2E+sGgEvWY0Yj7zqLa8en9nPj/xeryF6G4+RHJHvKlbdj7xY1a80318Ppcpj7yRgX8+Py7IvLs7fj4iaQS9xHF4PpxWHr3btW8+D3wnvSq+Zj6NLhm9jV1hPoaf77zwEGI+9MWavMR6aT4lkCy8F3N1PsR/CLzWd4A+kHVrvCtGgz5v5tq8
Converts to hex dump
89618bbe 052317bd ffb56d3e 100643bd ff9c623e a93f0fbd 60b1633e a6029dbc e0be6e3e 044615bc 1bce7c3e 10b418bc cdd4823e 523b96bc e0ab823e 1d86f5bc cba97d3e 6c6f19bd 898c723e 1dc918bd c8206b3e a278fabc 19e1693e b241adbc 52b36e3e 2d355ebc 76da763e 3d932fbc c8b67e3e 64265bbc fe5f813e b755a3bc 13eb803e 0638dfbc bd527c3e 78e502bd 8b5f753e 265704bd 13b36f3e b3f7e7bc a9e86d3e 306fb2bc ccea703e 51f283bc 4631763e 2ac550bc 79d77c3e c4745ebc cfef803e a54796bc 6b4f813e 901bcebc 3db57e3e 7061ffbc 22d2773e 866b08bd 6105713e fd52fcbc 5e4c6d3e 6125c9bc 4d736e3e 2d458dbc 8f44743e 6ac545bc 30937c3e a6b53fbc 1ab2813e 082189bc 4bc8823e cf5dcdbc a7da803e e08408bd d349793e db5318bd f9e86f3e f1230fbd 0c486a3e 5eb1dfbc 27f36a3e e82391bc e3fc713e a6bd2cbc 63a67c3e 4ae818bc a4fa823e 73987bbc 88a5843e b62bd8bc c23b823e f12818bd 8a92793e ee282ebd 4cb96d3e 637f23bd d860663e 5c70fabc 85da663e 9f1498bc d4246f3e 20e720bc 2cd87b3e 72630abc 2c52833e 998080bc 70fc843e a6cbeabc 23da813e 96d126bd aae8763e e3973cbd 276d693e 09492cbd d4c6613e fb49fabc 8c87633e 47b28bbc 20df6d3e 3728fcbb 28487c3e 3cb4eabb daf1833e b88885bc e837853e 5507fdbc c44d813e 547b33bd 5807743e d52f47bd e9bd653e ae4c31bd 40615e3e eb26f8bc 8319613e a5cf82bc 54b86c3e 1b86d8bb ab087c3e 9a2fe0bb e2da833e 45578cbc d5c5843e 2c7505bd 5542803e b59e3abd bb3e713e c5d34bbd 0eda623e 30f331bd d0d55b3e 4072f6bc 8e245f3e 8b377dbc 87466b3e abadd1bb 2ea77a3e f984e9bb 57f8823e 2d328fbc 5ec1833e 06ab06bd 7b7f7e3e f04b3abd 746d6f3e ddf94abd 966a613e 6bc331bd 677d5a3e bca9f8bc 5a675d3e b30f85bc 67b6683e a464efbb b022773e 85b9f9bb 82fa803e c60c8bbc 3fea813e b542febc bedb7b3e 9c382fbd d8186e3e 137f3fbd ef02613e af7029bd 4c6f5a3e 0fabf1bc a7d55c3e 806585bc eb06673e 707100bc 777a743e 3b88f7bb beb37e3e 05ec80bc b88a803e dedae8bc d53d7a3e 201922bd 00e56d3e cc6c33bd 46af613e f46d21bd f2e85a3e e809ecbc 58495c3e fa5e88bc 2332653e c54e00bc d69c713e 81ead5bb 73057c3e ded255bc 0a8e7f3e 4beac8bc 84bd7a3e 55c811bd 0e19703e d68927bd 5f66643e 0ebc1dbd 72b85c3e 4e69f4bc 213c5c3e bfd797bc c0d3623e b7d81bbc b1996d3e ea9ad1bb 22e7773e a51d2bbc 71f37c3e 9ddda1bc c8c97a3e 7ab3f5bc 8a78723e 1ea114bd 8419683e 993614bd 4b30603e ba3ff2bc 4f025e3e 299da3bc 7169623e 6c1935bc f46b6b3e 93e8d7bb 532c753e 16d908bc d5747b3e f68281bc 07857b3e 843dcebc d9a6753e 79f503bd 97826c3e 0f360bbd 9b6f643e 74f4f3bc 4bb6603e 9e3bb0bc e40f633e 892351bc 44536a3e d6f1e8bb 0ec8733e e2b7e6bb 1a6c7b3e a3c04dbc 13ca7d3e e497afbc 0d377a3e f4a9f3bc bd49723e 71260bbd d381693e cf3905bd 7e85633e fc4ed8bc 5b90623e af3d92bc e533673e 184f2ebc 595a6f3e 4148febb b0b3773e 872324bc 1eb27c3e e7a489bc 8b647c3e 6ae1cebc 77e2763e 1d4401bd c8956e3e a61208bd f408673e 349ff2bc 1927633e ee08b7bc 64c4643e e01165bc ff356b3e 427e04bc ddec733e e437e4bb 40e07b3e 165039bc 36977f3e 05e59ebc 9ba67d3e 8d41e6bc 9a95763e 004a0abd bb6c6d3e 10130cbd e6ec653e 6f65ebbc e258633e 547ba3bc e2d6663e 363035bc 72a16f3e b5b9b4bb ecaa7a3e 1393d4bb 1da5813e 27cc68bc f0cb823e 9dbdd4bc 2eab7f3e 154c18bd d783733e 1ff22ebd a5f3653e 98f221bd 16f05c3e 5099e8bc a6255d3e 6a955cbc 4881673e ff146dba f71b793e 2b61313b f448853e f880dbbb 2000893e 769fdbbc 9644843e fa1445bd 8502713e 09926bbd 7489583e bb3243bd 9f6d4e3e 6052bbbc 7ae2593e 577de73a f83e743e b4aa293c 86c6853e 0ffb0bbb 15b4883e 331bcfbc 9d37833e 57ac30bd fc51753e b6a844bd 63d4673e 6bd62dbd 9a93613e b06804bd 6634623e f3a8b6bc 7a7f673e 3ff17abc 85e86e3e 447247bc a95b763e f16356bc d37d7c3e 97298fbc 91817f3e 3f2ec8bc bb3b7e3e 226904bd c471783e 9c561ebd dbb56f3e 0f7c27bd 2abe663e 8d2e19bd 8d5d613e 869fefbc f010623e f4c59abc c47a693e 25902cbc 1773753e c47f08bc d677803e 90756bbc 2b46833e 6fe6dabc
402 32-bits.
Or more nicely formatted and re-endian-ized.
Looks like values are encoded as IEEE 32-bit float scaled up by about 122 or some magic number - depending on which values first expected value is 28.62 and the last is 31.32 map to.
0 BE8B6189 BD172305 -0.272229 -0.036899*
1 3E6DB5FF BD430610 0.232140* -0.047613
2 3E629CFF BD0F3FA9 0.221302 -0.034973
3 3E63B160 BC9D02A6 0.222356 -0.019166
4 3E6EBEE0 BC154604 0.233150 -0.009111
5 3E7CCE1B BC18B410 0.246880 -0.009320
6 3E82D4CD BC963B52 0.255530 -0.018339
7 3E82ABE0 BCF5861D 0.255218 -0.029971
8 3E7DA9CB BD196F6C 0.247718 -0.037460
9 3E728C89 BD18C91D 0.236864 -0.037301
10 3E6B20C8 BCFA78A2 0.229617 -0.030575
...
195 3E615D8D BCEF9F86 0.220083 -0.029251
196 3E6210F0 BC9AC5F4 0.220768 -0.018893
197 3E697AC4 BC2C9025 0.228007 -0.010532
198 3E757317 BC087FC4 0.239697 -0.008331
199 3E8077D6 BC6B7590 0.250914 -0.014371*
200 3E83462B BCDAE66F 0.256395* -0.026721
... it is possible that they are calculated from real and imaginary components.
Note, with ignoring the first data value:
last complex pair magnitude / first complex pair magnitude
|-0.014371 + 0.256395 * i| / | -0.036899 + 0.232140 * i| is 1.093...
Much like 31.32/28.62 is 1.094...
I'm running a SOLR with a set of OSM Addresses.
On the other hand I have some polygons in the same collection.
I got the JTS in my solr, everything is working fine.
My problem: For example the user is searching for a specific address like this:
/solr/select?q=Bruhweg&wt=json
The result will look like something like this:
"type":["Feature"],
"wkt":["POLYGON((9.0650999 48.80407349974092,9.065108 48.80405349974092,9.0651604 48.804044599740934,9.0651758 48.80405819974092,9.0652663 48.804044699740935,9.0652795 48.804077499740934,9.065298 48.804074799740924,9.06531 48.80411229974091,9.0653315 48.80411249974092,9.0653495 48.804152299740906,9.0653595 48.804185299740894,9.065227 48.8042043997409,9.0652154 48.804206599740894,9.0652046 48.80417829974089,9.0651805 48.8041809997409,9.065163500000002 48.8041373997409,9.0651464 48.8041391997409,9.0651335 48.80409639974092,9.0651051 48.80409789974092,9.0650999 48.80407349974092))"],
"properties.label":"Bruhweg 11"
"properties.category":"address"
where the field "wkt" is matched to the correct SOLR Type, which we can simply verify with the following request:
solr/select?fq=wkt%3A%22Intersects(9.0650999%2048.80407349974092)%22&q=&wt=json*
Notice that I have just taken the first coordinate from "Bruhweg 11" polygon. The result looks like this:
"type":["Feature"],
"wkt":["POLYGON((9.0650999 48.80407349974092,9.065108 48.80405349974092,9.0651604 48.804044599740934,9.0651758 48.80405819974092,9.0652663 48.804044699740935,9.0652795 48.804077499740934,9.065298 48.804074799740924,9.06531 48.80411229974091,9.0653315 48.80411249974092,9.0653495 48.804152299740906,9.0653595 48.804185299740894,9.065227 48.8042043997409,9.0652154 48.804206599740894,9.0652046 48.80417829974089,9.0651805 48.8041809997409,9.065163500000002 48.8041373997409,9.0651464 48.8041391997409,9.0651335 48.80409639974092,9.0651051 48.80409789974092,9.0650999 48.80407349974092))"],
"properties.label":"Bruhweg 11"
"properties.category":"address"
"type":["Feature"],
"wkt":["POLYGON((9.04226364394244 48.78375351560371,9.056374594613018 48.78376897799828,9.059599869694331 48.78163342420202,9.081809522348271 48.78162969553386,9.081761686040636 48.78226547394644,9.082034238895682 48.78253237030596,9.0856383112481 48.783065728036505,9.081013408886774 48.784895520573016,9.08026549061692 48.78523860978792,9.075279465525824 48.78709720944531,9.075385415333642 48.78784623302399,9.075233988916805 48.78855044494239,9.07538936442188 48.789573632543714,9.076086792392704 48.7899895067132,9.076400978454831 48.79076807795856,9.076954863544922 48.791675940101136,9.077323565779931 48.79247426327167,9.077661454940172 48.79359088232947,9.07820886975919 48.79468135994337,9.078817709274189 48.79498392847467,9.079201898938019 48.79520667445914,9.08016333903955 48.79554857516962,9.079778914425672 48.79518198750416,9.079578091974522 48.79467583486249,9.07960878146339 48.79427927263826,9.079777474351143 48.794273758443296,9.079890211573053 48.79495800149708,9.08018722352202 48.795156515552904,9.080499405509059 48.795473674672415,9.080691862967708 48.795850379952874,9.080924981851217 48.79602374816294,9.081213923069749 48.79636161227024,9.08216503129647 48.797025378100585,9.082445049467385 48.796812064430696,9.082997510785853 48.79666782293686,9.083016532890815 48.798210792078066,9.084546369553149 48.79818997904426,9.08436196313672 48.79857684935421,9.084539100024378 48.798725962114545,9.084861025057869 48.79994602380419,9.084990671623789 48.80091802856458,9.08494424868377 48.80165186074672,9.085041682576207 48.80209339903589,9.08538756537159 48.802966378021715,9.086053469766966 48.80390370812341,9.085797560540206 48.803894003364,9.085814723600494 48.80437509265621,9.085407910580006 48.80612600144947,9.086188011009677 48.80771257109675,9.087281863093846 48.80971073096298,9.086304168618957 48.809607114458665,9.08560710806074 48.80961663014216,9.084061519923088 48.80938486330555,9.084077207035987 48.80980658042419,9.083543243778244 48.811250273222925,9.056400173581295 48.81120764569635,9.055584833918676 48.81131770190693,9.05233070753251 48.81010351728196,9.050449180583943 48.81143341235964,9.047719936766072 48.81048226708057,9.047480579846537 48.81086460229471,9.04435778697807 48.809744505510096,9.042626974936422 48.809303638995836,9.038908229735283 48.80850647660382,9.037144908448282 48.808184194812405,9.038129032787538 48.805980772861595,9.038328485640509 48.8051777307488,9.03824791543268 48.80471104904327,9.03876113924191 48.80479984728909,9.03889592317821 48.802984244443905,9.037701980314722 48.802949557020376,9.036369132836748 48.80272688628704,9.035368430087201 48.802290085608014,9.035368259304592 48.8020471956323,9.033685064639178 48.801228620567926,9.032644752493526 48.800737922085965,9.03217057774127 48.8000889091118,9.032098034258505 48.799508062093246,9.031417252535123 48.79921048432656,9.031802215987176 48.798784151506815,9.031441019924467 48.798238377399365,9.03225196905176 48.797687782137466,9.033547957749326 48.79595641436032,9.038695453795164 48.79394510865497,9.03934415364024 48.7933001500083,9.041676969957162 48.7917058788909,9.043068750531523 48.789672193708604,9.043444520390391 48.788257529857816,9.043555307907576 48.787275490180576,9.042249027750703 48.785802079685375,9.042512195810728 48.784854079302804,9.042199907427747 48.7840458175582,9.04226364394244 48.78375351560371))"],
"properties.label":"polygonA",
"properties.category":"polygons"
What I want:
If the user is just searching for Bruhweg I want as result the address AND the polygonA from category polygons
Any Idea how to solve this?
I have a case where I want to load map objects located inside users viewport.
This is how I create users viewport rectangle:
DbGeography viewport_rectangle = DbGeography.FromText(string.Format("POLYGON(({0} {1}, {0} {2}, {3} {2}, {3} {1}, {0} {1}))", lon_min, lat_min, lat_max, lon_max));
Then I want to select all objects (Points, PolyLines, Polygons, located inside that rectangle):
var objects = db.mapobjects.Where(x => !x.LocationGeographic.Intersects(viewport_rectangle));
Everything until here works fine. The problem occours if PolyLine/Polygon is not entirely contained inside the viewport polygon. In this case it's ignored and I get "no objects" instead of objects, where some points/edges are out of the viewport.
Is there any alternative to "Intersects"? I want to select objects contained in the viewport rectangle, regardless if they are inside at all, or if only one small part of them is inside of the viewport rectangle.
viewport_rectangle = {SRID=4326;POLYGON ((15.693584159016611
46.532346466357438, 15.693584159016611 46.532770863495614, 15.695530101656916 46.532770863495614, 15.695530101656916 46.532346466357438, 15.693584159016611 46.532346466357438))}
Object which is only partially located inside viewport_rectangle and should be returned as a result:
LINESTRING (15.694189164787527 46.532622094224166, 15.694309193640944
46.532614944062828, 15.694392677396532 46.5326121762582, 15.694401059299702 46.532662919320614, 15.694536175578829 46.532621632923423, 15.694564338773485 46.532659690218026, 15.694584455341097 46.532614944062828, 15.694570373743769 46.532578039989573, 15.694489236921068 46.53258611275777, 15.694502312690016 46.532539290685662, 15.694723930209872 46.53252614359414, 15.69474438205361 46.532575041532539, 15.694786962121723 46.532516225610692, 15.694763492792843 46.532481858630774, 15.694699790328738 46.532507922181281, 15.694884862750767 46.532493852478581, 15.694849658757446 46.53254505695287)
One part of LINQ generated query:
SELECT
[Filter1].[ObjectId] AS [ObjectId],
[Filter1].[LocationGeographic] AS [LocationGeographic],
FROM (SELECT [Extent1].[ObjectId] AS [ObjectId], [Extent1].[LocationGeographic] AS [LocationGeographic]
FROM [dbo].[mapobjects] AS [Extent1]
WHERE (([Filter1].[LocationGeographic].STIntersects(#p__linq__0)) <> cast(1
as bit))
) AS [Project1]
Edited:
the correct order of viewport_rectangle should be:
DbGeography viewport_rectangle = DbGeography.FromText(string.Format("POLYGON(({0} {1}, {2} {1}, {2} {3}, {0} {3}, {0} {1}))", lon_min, lat_min, lon_max, lat_max));
You appear to have a ring orientation problem with your polygon. The order in which you specify your points matters. The polygon, as you've defined it, is the entire globe minus a very small square (presumably, your desired viewport). How did I determine this?
declare #line geography = geography::STGeomFromText('LINESTRING (15.694189164787527 46.532622094224166, 15.694309193640944 46.532614944062828, 15.694392677396532 46.5326121762582, 15.694401059299702 46.532662919320614, 15.694536175578829 46.532621632923423, 15.694564338773485 46.532659690218026, 15.694584455341097 46.532614944062828, 15.694570373743769 46.532578039989573, 15.694489236921068 46.53258611275777, 15.694502312690016 46.532539290685662, 15.694723930209872 46.53252614359414, 15.69474438205361 46.532575041532539, 15.694786962121723 46.532516225610692, 15.694763492792843 46.532481858630774, 15.694699790328738 46.532507922181281, 15.694884862750767 46.532493852478581, 15.694849658757446 46.53254505695287)', 4236),
#poly geography = geography::STGeomFromText('POLYGON ((15.693584159016611 46.532346466357438, 15.693584159016611 46.532770863495614, 15.695530101656916 46.532770863495614, 15.695530101656916 46.532346466357438, 15.693584159016611 46.532346466357438))', 4236);
select #poly.EnvelopeAngle(); --returns 180
select #poly.ReorientObject().STIntersects(#line); --returns 1
Best you read up on the EnvelopeAngle() method yourself. But I'll say this - I use it as a quick heuristic to detect the ring orientation problem you have here. Invariably, if a polygon has this problem, the envelope angle will be 180 (which is almost never what you intended).
I've also given away the punchline on how to fix it in the code above; calling ReorientObject() on the polygon changes clockwise to counterclockwise (and vice versa).
Finally, it looks like your line string was fully contained within your viewport; I tested with STContains(). Which explains why you were getting false before when what you thought was your viewport was everything but the viewport!
I'd like to understand the meaning of this error:
Error: ERROR: GEOSUnaryUnion: TopologyException: side location conflict at 509222.06405540626 166742.77073020922
SQLState: XX000
ErrorCode: 0
Given from the following query:
select ST_union(z.geom) from zaz z
Postgis version:
POSTGIS="2.1.0 r11822"
GEOS="3.3.6-CAPI-1.7.6"
PROJ="Rel. 4.8.0, 6 March 2012"
GDAL="GDAL 1.9.2, released 2012/10/08"
LIBXML="2.9.0" RASTER
The problem can be reproduced with this query:
select ST_AsText(ST_Union(z.geom)) from (
select ST_MPolyFromText('MULTIPOLYGON(((513571.981531803 166341.349774259,513116.037800698 166090.997380913,513119.013934713 166083.021341753,513122.34720481 166072.188213938,513124.013839858 166065.997855187,513126.037610988 166046.950597491,513126.037610988 166023.974842894,513117.942526467 165913.024566813,513116.990163582 165897.905806017,513104.966582162 165803.502835059,513104.60944608 165716.718767181,513124.013839858 164966.018723224,513054.967530709 164991.018248951,513040.682087437 164995.065791211,512771.639572476 165072.207184881,512658.070298462 165089.230671447,512620.332919151 165094.825803396,512222.007142577 165144.705809488,512088.319202621 165158.396025957,511825.467046411 165185.300277453,511437.260125488 165216.25207121,511039.767666438 165238.394508282,510637.275302243 165245.299139197,510278.115449307 165247.084819606,509844.671291355 165243.275368066,509480.630578634 165236.01360107,509195.516939992 165227.918516549,508870.642150909 167051.217259529,509104.804375213 166841.340288788,509222.064055406 166742.770730209,509415.631811745 166631.106181965,509727.887792604 166450.871506013,509849.6711965 166401.824817445,509922.407911828 166380.753788619,509986.811451913 166352.659083516,510105.975857876 166299.445807327,510225.259309199 166266.232151719,510464.302393288 166229.209044572,510544.777057055 166213.495056973,510668.227095999 166170.876817877,510762.034840154 166140.282160202,510828.938332812 166126.949079815,510890.365738883 166118.139723131,510959.05491195 166107.782776758,511018.33950153 166100.16387368,511066.076691131 166092.42592524,511097.742757051 166089.211700504,511281.786884542 166098.021057189,511590.471504583 166137.90125299,511730.825984733 166143.853521021,511766.896728995 166143.972566381,511806.419788715 166145.520156069,511905.108392654 166136.353663303,512001.535134742 166108.735139643,512202.95988488 166038.379331527,512434.145975169 165984.332737814,512507.120781218 165968.618750214,512581.643176955 165965.642616199,512654.379892283 166077.307164444,512784.496471421 166043.855418115,512787.948786879 166078.973799492,512787.948786879 166078.973799492,512767.830120937 166133.377529288,512774.020479688 166276.23196201,512799.020005415 166301.350533097,512836.400248644 166276.946234174,512874.018582594 166305.040939276,512838.066883692 166334.564188705,512845.090559968 166427.895751417,512806.996044575 166460.990361664,512846.757195016 166499.561058499,512858.899821797 166718.723567368,512820.329124962 166737.770825064,512833.900296071 166747.532544633,512821.043397126 166755.984765236,512877.708988772 166768.365482739,512893.899157814 166775.627249735,512930.68417424 166780.270018799,512977.469000957 166786.103241468,513181.393703668 166834.554703233,513269.011089071 166852.054371242,513314.605462182 166864.077952663,513568.886352428 166930.624309239,513908.760856946 167004.313387452,513964.593131069 167015.265560627,514336.967019032 167086.454686267,514356.252367449 167090.264137806,514374.10917154 167095.621179034,514433.274715759 166842.649787754,514423.036814747 166834.554703233,514403.037194166 166819.197851716,514302.443864457 166749.675361124,513950.664823878 166560.750373849,513571.981531803 166341.349774259)))') as geom
union
select ST_MPolyFromText('MULTIPOLYGON(((509658.841483455 166823.126348616,509700.031178223 166767.055983772,509737.292376092 166816.816944504,509780.982023433 166778.008156947,509821.338400677 166825.269165106,509862.051914003 166803.960045559,509727.887792604 166450.871506013,509415.631811745 166631.106181965,509480.987714716 166813.959855849,509442.417017881 166923.362542242,509390.751331379 167281.570032294,509425.988758117 167342.997438364,509448.012149829 167345.97357238,509478.963943585 167352.04488577,509503.963469312 167355.021019785,509530.986766168 167357.9971538,509555.986291895 167357.9971538,509583.961951636 167358.949516685,509588.009493897 167357.9971538,509603.009209333 167068.955018259,509651.579716458 167025.622507,509658.841483455 166823.126348616)),((509222.064055406 166742.770730209,509288.967548065 167023.955871951,509248.373080099 167078.002465664,509288.967548065 167023.955871951,509222.064055406 166742.770730209)))') as geom
) z
I'd also like to know if there is a way to "fix" one of the geometries to avoid
the error.
Strangely, if I create a table with a union of the two above selects, and then run an ST_Union, then it doesn't fail.
ST_MakeValid solves the problem.
The result can be passed to ST_Union:
ST_Union(st_makeValid(t.geom))
For the explanation, it could not be better than this one: PostGIS: Tips for power users.