* Map Life Fact code chunk

Writing and using plugins for Version 5 and above.
Post Reply
User avatar
Ron Melby
Superstar
Posts: 494
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Map Life Fact code chunk

Post by Ron Melby » 15 Feb 2020 03:56

for Mike Tate I guess:

I am adding several fhSetLabelledText fields to SOUR records after what Map Life Facts enter in Latitude and Longitude.

So far so good, and it appears that MLF cleans out old unused addr and plac records, all well and fine for the addr sour records, it takes care of the issue for me.

the problem I have is with place records, I am currently not saving my heavy processing of google api in place tables and not saving the place table permanantly. that is not a major thing to save and load the tables I make after the run.

so, ADDR_SOUR RECORDS TAKE CARE OF THEMSELVES after MLF is run.

If I build place tables and store information in them, how do I detect unused place table entries, to cull them from the table? I cannot fathom how you do it, and have been looking at that code awhile, it is too --- uhhhh 'densely packed' for me to follow. to find a new record, doesnt seem so tough in my code, but to find the unused is a puzzle. how is it done and where (I see DeleteLocationRecord but dont understand that either, let alone getting there)

Thanks in advance.






H
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 17368
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Map Life Fact code chunk

Post by tatewise » 15 Feb 2020 10:42

If I understand your problem correctly, the solution is to use the FH Place Records.
The specific details depend on the primary key in your place table. Is it Place Name or Record Id?

If you use Place Name, loop through all _PLAC records and build a dictionary of Place Names:

Code: Select all

local dicPlace = { }
local ptrPlace = fhNewItemPtr()
ptrPlace:MoveToFirstRecord("_PLAC")
while ptrPlace:IsNotNull() do
    local strPlace = fhGetItemText(ptrPlace,"~.TEXT")
    dicPlace[strPlace] = true
    ptrPlace:MoveNext()
end
Then loop through your place table and test each Place Name:

Code: Select all

for strPlace, tblData in pairs(tblPlace) do
    if not dicPlace[strPlace] then
        tblPlace[strPlace] = nil     -- Delete unused place table entry
    end
end
Alternatively, if you use Record Id, loop through all _PLAC records and build a dictionary of Record Id:

Code: Select all

local dicPlace = { }
local ptrPlace = fhNewItemPtr()
ptrPlace:MoveToFirstRecord("_PLAC")
while ptrPlace:IsNotNull() do
    local intPlace = fhGetRecordId(ptrPlace)
    dicPlace[intPlace] = true
    ptrPlace:MoveNext()
end
Then use a similar loop as above to delete unused place table entries by Record Id.

Map Life Facts is more complex because it has to handle a variety of different scenarios.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Superstar
Posts: 494
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Map Life Fact code chunk

Post by Ron Melby » 15 Feb 2020 13:19

Thanks. I am still unable to route my cemeteries, but am gathering the information I need to do it, and saving it in tables because to run even what I have now, it takes a while to do it over and over by api every time.
FH V.6.2.7 Win 10 64 bit

User avatar
Ron Melby
Superstar
Posts: 494
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Map Life Fact code chunk

Post by Ron Melby » 15 Feb 2020 19:18

well, that was over before it started, there is no iuplua_plot library in FH

or I am doing something totally wrong. can any of the IUP killers help me?
FH V.6.2.7 Win 10 64 bit

User avatar
Ron Melby
Superstar
Posts: 494
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Map Life Fact code chunk

Post by Ron Melby » 15 Feb 2020 20:16

the examples and documentation are wrong or this lua is way out of date.

I am using iuplua_pplot

it appears as though I can do more than 20 plots, we shall see.
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 17368
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Map Life Fact code chunk

Post by tatewise » 15 Feb 2020 21:19

Are you talking about the page of IUP documentation headed IupPlot (since 3.12)?
See Knowledge Base > IUP GUI Builder References where it says v3.11.2 in ƒh V6, so v3.12 features are not included.
The online versions & documentation keep marching forward, but the Lua & IUP versions built into FH are frozen in time.

There may be an earlier version and I've seen a message saying require("iuplua_pplot") was missing from example.

What has any of this got to do with the Subject: Map Life Fact code chunk ?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Superstar
Posts: 494
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Map Life Fact code chunk

Post by Ron Melby » 16 Feb 2020 14:05

getting the information from the apis, installing them in in my code, keeping them synched, being able to plot them, in a graph or on a ... haven't gotten this far yet, but I think its going to be a 'leaf' is all something map life facts does more or less, and I am using that (where I can understand it) as a robust pattern for my code.
FH V.6.2.7 Win 10 64 bit

Post Reply